diff --git a/src/common-components/button-question/button-question.spec.js b/src/common-components/button-question/button-question.spec.js index 132e5edb9..eb2308ca0 100644 --- a/src/common-components/button-question/button-question.spec.js +++ b/src/common-components/button-question/button-question.spec.js @@ -2,14 +2,6 @@ import { shallowMount, mount } from "@vue/test-utils"; import buttonQuestion from "@/common-components/button-question/button-question"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; -jest.mock( - "@/store", - () => { - return {}; - }, - { virtual: true } -); - describe("buttonQuestion.vue", () => { it("Should show overflow classes on fieldset if isOverflowScrollable is true", () => { // Act diff --git a/src/common-components/dropdown-question/dropdown-question.spec.js b/src/common-components/dropdown-question/dropdown-question.spec.js index 20bba1712..a606e3d19 100644 --- a/src/common-components/dropdown-question/dropdown-question.spec.js +++ b/src/common-components/dropdown-question/dropdown-question.spec.js @@ -23,8 +23,6 @@ describe("dropdownQuestion.vue", () => { mixins: [mockMixin], }); - wrapper.getCmsContent = jest.fn(); - // Act const select = wrapper.find("select"); diff --git a/src/ux-components/button-main/button-main.spec.js b/src/ux-components/button-main/button-main.spec.js index 816a83e55..cd434cfec 100644 --- a/src/ux-components/button-main/button-main.spec.js +++ b/src/ux-components/button-main/button-main.spec.js @@ -4,89 +4,77 @@ import { getMountOptions } from "@/helpers/unit-test-helper.js"; import { nextTick } from "vue"; describe("buttonMain.vue", () => { - it("Should return btn-primary class", async () => { - // Act + it("Should return btn-primary class", () => { + // Arrange/Act const wrapper = shallowMount( buttonMain, setupMocks({ - propsData: { + props: { isPrimary: true, }, }) ); - - // Assert const button = wrapper.find("button"); - - // Expect + + // Assert expect(button.attributes("class")).toContain("btn-primary"); }); - it("Should return aria-disabled state", async () => { - // Act + it("Should return aria-disabled state", () => { + // Arrange/Act const wrapper = shallowMount( buttonMain, setupMocks({ - propsData: { + props: { isDisabled: true, }, }) ); - - // Assert const button = wrapper.find("button"); - // Expect + // Assert expect(button.attributes()["aria-disabled"]).toEqual("true"); }); it("Should return loader color", async () => { - // Act + // Arrange const wrapper = shallowMount( buttonMain, setupMocks({ - propsData: { + props: { loaderColor: "blue", loaderEnabled: true, }, }) ); - // Assert - - const label = wrapper.find("label"); - + // Act wrapper.vm.clicked(); - await nextTick(); - + + // Assert const loader = wrapper.find("loader-stub"); - expect(loader.attributes("class")).toContain("blue"); }); it("Should return loader position", async () => { - // Act + // Arrange const wrapper = shallowMount( buttonMain, setupMocks({ - propsData: { + props: { loaderPosition: "right", loaderEnabled: true, }, }) ); - - // Assert - - const label = wrapper.find("label"); - + + // Act wrapper.vm.clicked(); - await nextTick(); - + + // Assert const loader = wrapper.find("loader-stub"); - expect(loader.attributes("class")).toContain("right"); }); }); diff --git a/src/ux-components/loader/loader.spec.js b/src/ux-components/loader/loader.spec.js index 3d0843e10..43b613e6b 100644 --- a/src/ux-components/loader/loader.spec.js +++ b/src/ux-components/loader/loader.spec.js @@ -1 +1,32 @@ -test.todo("some test to be written in the future"); +import { shallowMount, mount } from "@vue/test-utils"; +import loader from "./loader"; + +describe("loader.vue", () => { + test("if it rendered the HTML element with class", () => { + // Arrange/Act + const wrapper = shallowMount(loader, { + props: {}, + }); + + // Assert + expect(wrapper.find('div').exists()).toBeTruthy(); + expect(wrapper.find('.loader').exists()).toBeTruthy(); + }); + + test("if it correctly passed props", () => { + // Arrange/Act + const wrapper = shallowMount(loader, { + props: { + loaderColor: "blue", + loaderPosition: "left" + }, + }); + + // Assert + expect(wrapper.props()).toMatchObject({ + loaderColor: "blue", + loaderPosition: "left", + }); + }); + +}); \ No newline at end of file