From 36b5d2894678262f8a30b6da0b53193fceb6b98f Mon Sep 17 00:00:00 2001 From: Zara Mudassar <zara.1310@hotmail.com> Date: Tue, 26 Apr 2022 13:35:14 +0200 Subject: [PATCH] item card related files deleted, now this branch only includes adding new item related files --- src/components/AddNewItem.vue | 3 +- src/router/index.js | 5 --- tests/unit/add-new-item.spec.js | 64 ++++++++++++++++----------------- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/src/components/AddNewItem.vue b/src/components/AddNewItem.vue index e1cd2e8..cfe5ea6 100644 --- a/src/components/AddNewItem.vue +++ b/src/components/AddNewItem.vue @@ -10,7 +10,8 @@ <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" id="titleLabel" - >Tittel</label> + >Tittel</label + > <input type="text" id="title" diff --git a/src/router/index.js b/src/router/index.js index 6529bc2..acdbd47 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -27,11 +27,6 @@ const routes = [ name: "addNewItem", component: () => import("../views/AddNewItemView.vue"), }, - { - path: "/itemCard", - name: "itemCard", - component: () => import("../views/ItemCardView.vue"), - }, ]; const router = createRouter({ diff --git a/tests/unit/add-new-item.spec.js b/tests/unit/add-new-item.spec.js index fd33aed..930eceb 100644 --- a/tests/unit/add-new-item.spec.js +++ b/tests/unit/add-new-item.spec.js @@ -2,37 +2,35 @@ import { shallowMount } from "@vue/test-utils"; import AddNewItem from "@/components/AddNewItem.vue"; describe("addNewItem elements rendering", () => { - - it("renders all labels", () => { - - const wrapper = shallowMount(AddNewItem); - - expect(wrapper.find('#titleLabel').text()).toMatch("Tittel"); - expect(wrapper.find('#selectCategoryLabel').text()).toMatch("Kategori"); - expect(wrapper.find('#priceLabel').text()).toMatch("Pris"); - expect(wrapper.find('#descriptionLabel').text()).toMatch("Beskrivelse"); - expect(wrapper.find('#imageLabel').text()).toMatch("Bilde"); - - }); - - it("Tests setting values of input field", async() => { - - const wrapper = shallowMount(AddNewItem); - - const titleInput = wrapper.find('#title'); - await titleInput.setValue("Dyson"); - expect(titleInput.element.value).toBe("Dyson"); - - const selectedCategory = wrapper.find('#categories'); - await selectedCategory.setValue("Hage"); - expect(selectedCategory.element.value).toBe("Hage"); - - const priceInput = wrapper.find('#price'); - await priceInput.setValue(500); - expect(priceInput.element.value).toBe("500"); - - const descriptionInput = wrapper.find('#description'); - await descriptionInput.setValue("Dette er en støvsuer fra Dyson"); - expect(descriptionInput.element.value).toBe("Dette er en støvsuer fra Dyson"); - }); + it("renders all labels", () => { + const wrapper = shallowMount(AddNewItem); + + expect(wrapper.find("#titleLabel").text()).toMatch("Tittel"); + expect(wrapper.find("#selectCategoryLabel").text()).toMatch("Kategori"); + expect(wrapper.find("#priceLabel").text()).toMatch("Pris"); + expect(wrapper.find("#descriptionLabel").text()).toMatch("Beskrivelse"); + expect(wrapper.find("#imageLabel").text()).toMatch("Bilde"); + }); + + it("Tests setting values of input field", async () => { + const wrapper = shallowMount(AddNewItem); + + const titleInput = wrapper.find("#title"); + await titleInput.setValue("Dyson"); + expect(titleInput.element.value).toBe("Dyson"); + + const selectedCategory = wrapper.find("#categories"); + await selectedCategory.setValue("Hage"); + expect(selectedCategory.element.value).toBe("Hage"); + + const priceInput = wrapper.find("#price"); + await priceInput.setValue(500); + expect(priceInput.element.value).toBe("500"); + + const descriptionInput = wrapper.find("#description"); + await descriptionInput.setValue("Dette er en støvsuer fra Dyson"); + expect(descriptionInput.element.value).toBe( + "Dette er en støvsuer fra Dyson" + ); + }); }); -- GitLab