From c70f863d4f506ce70e6159465a3ebe78efbd6e6a Mon Sep 17 00:00:00 2001 From: Tanmay1201 Date: Sun, 15 Mar 2020 15:06:50 +0530 Subject: [PATCH 1/2] Addition of unit tests for FirstStep.js --- tests/unit/FirstStep.spec.js | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tests/unit/FirstStep.spec.js diff --git a/tests/unit/FirstStep.spec.js b/tests/unit/FirstStep.spec.js new file mode 100644 index 00000000..2b78ab84 --- /dev/null +++ b/tests/unit/FirstStep.spec.js @@ -0,0 +1,79 @@ +import { mount } from "@vue/test-utils"; +import FirstStep from "@/Components/FirstStep.vue"; + +describe("FirstStep.vue", () => { + const wrapper = mount(FirstStep); + it("Has the main div tag", () => { + expect(wrapper.contains(".step-content")).toBe(true); + }); + + it("renders without any errors", () => { + expect(wrapper.isVueInstance()).toBeTruthy(); + }); + + it("Checks if the cardtext function return the correct answer when selected is true", () => { + wrapper.setProps({ + selected: true + }); + + expect(wrapper.vm.cardText).toBe("stepper.FS.selected"); + }); + + it("Checks if the cardtext function return the correct answer when selected is false", () => { + wrapper.setProps({ + selected: false + }); + + expect(wrapper.vm.cardText).toBe("stepper.FS.not-selected"); + }); + + it("Checks if the yesText function returns correct answer", () => { + expect(wrapper.vm.yesText).toBe("stepper.FS.selected"); + }); + + it("Checks if the yesText function returns correct answer", () => { + expect(wrapper.vm.noText).toBe("stepper.FS.not-selected"); + }); + + it("Checks if the yesSelected function returns the correct boolean when selected is true", () => { + wrapper.setProps({ + selected: true + }); + expect(wrapper.vm.yesSelected).toBe("selected"); + }); + + it("Checks if the yesSelected function returns the correct boolean when selected is false", () => { + wrapper.setProps({ + selected: false + }); + expect(wrapper.vm.yesSelected).toBe("not-selected"); + }); + + it("Checks if the get function in radio returns the correct value when selected is undefined", () => { + wrapper.setProps({ + selected: undefined + }); + expect(wrapper.vm.radio).toBe(undefined); + }); + + it("Checks if the get function in radio returns the correct value when selected is yes", () => { + wrapper.setData({ + selected: "yes" + }); + expect(wrapper.vm.radio).toBe("yes"); + }); + + it("Checks if the noSelected function returns the correct boolean when selected is true", () => { + wrapper.setProps({ + selected: true + }); + expect(wrapper.vm.noSelected).toBe("not-selected"); + }); + + it("Checks if the noSelected function returns the correct boolean when selected is false", () => { + wrapper.setProps({ + selected: false + }); + expect(wrapper.vm.noSelected).toBe("selected"); + }); +}); From d54618b6518922bfd7c6b792e4bad911331fca8b Mon Sep 17 00:00:00 2001 From: Tanmay1201 Date: Mon, 16 Mar 2020 21:52:49 +0530 Subject: [PATCH 2/2] change the name of the function from yes to no --- tests/unit/FirstStep.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/FirstStep.spec.js b/tests/unit/FirstStep.spec.js index 2b78ab84..02e3f774 100644 --- a/tests/unit/FirstStep.spec.js +++ b/tests/unit/FirstStep.spec.js @@ -27,11 +27,11 @@ describe("FirstStep.vue", () => { expect(wrapper.vm.cardText).toBe("stepper.FS.not-selected"); }); - it("Checks if the yesText function returns correct answer", () => { + it("Checks if the yesText function returns correct answer ", () => { expect(wrapper.vm.yesText).toBe("stepper.FS.selected"); }); - it("Checks if the yesText function returns correct answer", () => { + it("Checks if the noText function returns correct answer", () => { expect(wrapper.vm.noText).toBe("stepper.FS.not-selected"); });