From e7fb39a3fb493c540c38f8396aa11f7f345c6c70 Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Tue, 8 Nov 2022 08:18:44 -0500 Subject: [PATCH 1/3] commit --- src/ux-components/checkbox/checkbox.spec.js | 0 src/ux-components/checkbox/checkbox.vue | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/ux-components/checkbox/checkbox.spec.js create mode 100644 src/ux-components/checkbox/checkbox.vue diff --git a/src/ux-components/checkbox/checkbox.spec.js b/src/ux-components/checkbox/checkbox.spec.js new file mode 100644 index 00000000..e69de29b diff --git a/src/ux-components/checkbox/checkbox.vue b/src/ux-components/checkbox/checkbox.vue new file mode 100644 index 00000000..e69de29b From d78da12a98d69cfdec15aee706d6e98cf568e4a4 Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Tue, 8 Nov 2022 08:25:12 -0500 Subject: [PATCH 2/3] commit --- src/ux-components/checkbox/checkbox.spec.js | 78 +++++++++++++++++++++ src/ux-components/checkbox/checkbox.vue | 65 +++++++++++++++++ 2 files changed, 143 insertions(+) diff --git a/src/ux-components/checkbox/checkbox.spec.js b/src/ux-components/checkbox/checkbox.spec.js index e69de29b..e231ecc7 100644 --- a/src/ux-components/checkbox/checkbox.spec.js +++ b/src/ux-components/checkbox/checkbox.spec.js @@ -0,0 +1,78 @@ +import { shallowMount } from "@vue/test-utils"; +import checkbox from "./checkbox"; +import { nextTick } from "vue"; + +describe("checkbox.vue", () => { + it("Should return checkbox name", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + checkboxName: "Checkbox", + }, + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes().name).toEqual("Checkbox"); + }); + + it("Should return checkbox id", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + buttonID: "Checkbox ID", + }, + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes().id).toEqual("Checkbox ID"); + }); + + it("Should return tabindex value", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + tabIndex: "1", + }, + }); + + // Assert + const input = wrapper.find("input"); + + // Expect + expect(input.attributes().tabindex).toEqual("1"); + }); + + it("Should return label text", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + checkboxLabel: "label text", + }, + }); + + // Assert + const paragraph = wrapper.find("p"); + + expect(paragraph.text()).toEqual("label text"); + }); + + it("Should return label text", async () => { + // Act + const wrapper = shallowMount(checkbox, { + propsData: { + screenReaderOnlyText: "screenreader text", + }, + }); + + // Assert + const paragraph = wrapper.find("span"); + + expect(paragraph.text()).toEqual("screenreader text"); + }); +}); diff --git a/src/ux-components/checkbox/checkbox.vue b/src/ux-components/checkbox/checkbox.vue index e69de29b..cbc1120c 100644 --- a/src/ux-components/checkbox/checkbox.vue +++ b/src/ux-components/checkbox/checkbox.vue @@ -0,0 +1,65 @@ + + + + + From 67da5172079d02c8cd6043ecd69d08dcb5f29717 Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Tue, 8 Nov 2022 15:28:27 -0500 Subject: [PATCH 3/3] Site footer changes. --- .../site-footer/site-footer.spec.js | 42 ++++++ .../site-footer/site-footer.vue | 132 +++++++++++++++++ .../button-main/button-main.spec.js | 102 +++++++++++++ src/ux-components/button-main/button-main.vue | 140 ++++++++++++++++++ 4 files changed, 416 insertions(+) create mode 100644 src/common-components/site-footer/site-footer.spec.js create mode 100644 src/common-components/site-footer/site-footer.vue create mode 100644 src/ux-components/button-main/button-main.spec.js create mode 100644 src/ux-components/button-main/button-main.vue diff --git a/src/common-components/site-footer/site-footer.spec.js b/src/common-components/site-footer/site-footer.spec.js new file mode 100644 index 00000000..8a4d8a69 --- /dev/null +++ b/src/common-components/site-footer/site-footer.spec.js @@ -0,0 +1,42 @@ +import { mount } from "@vue/test-utils"; +import siteFooter from "./site-footer"; + +describe("site-footer.vue", () => { + it("Should emit ForwardClicked on button click", async () => { + // Act + const wrapper = mount(siteFooter, { + mixins: [mockMixin], + }); + wrapper.vm.buttonClick(); + // Assert + expect(wrapper.emitted()["ForwardClicked"][0]).toHaveBeenCalled; + }); + + it("Should emit BackClicked on link click", async () => { + // Act + const wrapper = mount(siteFooter, { + mixins: [mockMixin], + }); + wrapper.vm.linkClick(); + // Assert + expect(wrapper.emitted()["BackClicked"][0]).toHaveBeenCalled; + }); + + it("Should change button text when update button text is called", async () => { + // Act + const wrapper = mount(siteFooter, { + mixins: [mockMixin], + }); + wrapper.vm.updateButtonText("newText"); + + // Assert + expect(wrapper.componentVM.customButtontext).toBe("newText"); + }); +}); + +const mockMixin = { + methods: { + getCmsContent: jest.fn(), + getFooterInfoBoxHeight: jest.fn(() => 80), + }, +}; diff --git a/src/common-components/site-footer/site-footer.vue b/src/common-components/site-footer/site-footer.vue new file mode 100644 index 00000000..2a611968 --- /dev/null +++ b/src/common-components/site-footer/site-footer.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/ux-components/button-main/button-main.spec.js b/src/ux-components/button-main/button-main.spec.js new file mode 100644 index 00000000..9fa8b10e --- /dev/null +++ b/src/ux-components/button-main/button-main.spec.js @@ -0,0 +1,102 @@ +import { shallowMount } from "@vue/test-utils"; +import buttonMain from "./button-main"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import { nextTick } from "vue"; + +describe("buttonMain.vue", () => { + it("Should return btn-primary class", async () => { + // Act + const wrapper = shallowMount( + buttonMain, + setupMocks({ + propsData: { + isPrimary: true, + }, + }) + ); + + // Assert + const button = wrapper.find("button"); + + // Expect + expect(button.attributes("class")).toContain("btn-primary"); + }); + + it("Should return aria-disabled state", async () => { + // Act + const wrapper = shallowMount( + buttonMain, + setupMocks({ + propsData: { + isDisabled: true, + }, + }) + ); + + // Assert + const button = wrapper.find("button"); + + // Expect + expect(button.attributes()["aria-disabled"]).toEqual("true"); + }); + + it("Should return loader color", async () => { + // Act + const wrapper = shallowMount( + buttonMain, + setupMocks({ + propsData: { + loaderColor: "blue", + loaderEnabled: true, + }, + }) + ); + + // Assert + + const label = wrapper.find("label"); + + wrapper.vm.clicked(); + + await nextTick(); + + const loader = wrapper.find("loader-stub"); + + expect(loader.attributes("class")).toContain("blue"); + }); + + it("Should return loader position", async () => { + // Act + const wrapper = shallowMount( + buttonMain, + setupMocks({ + propsData: { + loaderPosition: "right", + loaderEnabled: true, + }, + }) + ); + + // Assert + + const label = wrapper.find("label"); + + wrapper.vm.clicked(); + + await nextTick(); + + const loader = wrapper.find("loader-stub"); + + expect(loader.attributes("class")).toContain("right"); + }); +}); + +function setupMocks(mountOptionsMockData = {}) { + const defaultMountOptions = { route: { query: { issPage: "page-name" } } }; + const baseMountOptions = getMountOptions( + Object.assign(defaultMountOptions, mountOptionsMockData) + ); + const allMountOptions = Object.assign(defaultMountOptions, baseMountOptions); + + return allMountOptions; +} diff --git a/src/ux-components/button-main/button-main.vue b/src/ux-components/button-main/button-main.vue new file mode 100644 index 00000000..29234e1c --- /dev/null +++ b/src/ux-components/button-main/button-main.vue @@ -0,0 +1,140 @@ + + + + +