diff --git a/src/common-components/funnel-footer/funnel-footer.spec.js b/src/common-components/funnel-footer/funnel-footer.spec.js index 6b2bd8335..30dc14fd3 100644 --- a/src/common-components/funnel-footer/funnel-footer.spec.js +++ b/src/common-components/funnel-footer/funnel-footer.spec.js @@ -16,8 +16,8 @@ describe("funnel-footer.vue", () => { }); const wrapper = mount(funnelFooter, { + mixins: [mockMixin] }); - wrapper.vm.initializeComponent(cmsContent); // Assert const link = wrapper.find("a"); @@ -30,6 +30,7 @@ describe("funnel-footer.vue", () => { it("Should emit ForwardClicked on button click", async () => { // Act const wrapper = mount(funnelFooter, { + mixins: [mockMixin] }); wrapper.vm.buttonClick(); // Assert @@ -39,16 +40,28 @@ describe("funnel-footer.vue", () => { it("Should emit BackClicked on link click", async () => { // Act const wrapper = mount(funnelFooter, { + 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(funnelFooter, { + mixins: [mockMixin] + }); + wrapper.vm.updateButtonText('newText'); + + // Assert + expect(wrapper.componentVM.customButtontext).toBe('newText'); + }); + }); -//Mock CMS content -const cmsContent = { - backLink: "text", - buttonText: "text", -}; +const mockMixin = { + methods: { + getCmsContent: jest.fn() + } +} \ No newline at end of file diff --git a/src/common-components/funnel-footer/funnel-footer.vue b/src/common-components/funnel-footer/funnel-footer.vue index 4d9a47ee6..62b7d9147 100644 --- a/src/common-components/funnel-footer/funnel-footer.vue +++ b/src/common-components/funnel-footer/funnel-footer.vue @@ -58,6 +58,7 @@ export default { data() { return { paddingHeight: 0, + customButtontext: '', } }, mounted() { @@ -74,7 +75,7 @@ export default { return this.getCmsContent(this.cmsWidgetName, 'BackButtonText'); }, buttonText(){ - return this.getCmsContent(this.cmsWidgetName, 'ForwardButtonText'); + return this.customButtontext ? this.customButtontext : this.getCmsContent(this.cmsWidgetName, 'ForwardButtonText'); } }, methods: { @@ -82,7 +83,7 @@ export default { this.paddingHeight = document.querySelector(".footer #infoBox").offsetHeight; }, updateButtonText(newText) { - this.buttonText = newText; + this.customButtontext = newText; }, removeLoader(){ this.$refs.buttonMain.removeLoader(); diff --git a/src/common-components/funnel-header/funnel-header.spec.js b/src/common-components/funnel-header/funnel-header.spec.js index ed60d5f73..a9b9535aa 100644 --- a/src/common-components/funnel-header/funnel-header.spec.js +++ b/src/common-components/funnel-header/funnel-header.spec.js @@ -10,8 +10,8 @@ describe("funnelHeader", () => { setData: { imageSrc: "image_url", }, + mixins: [mockMixin] }); - wrapper.vm.initializeComponent(cmsContent); // Assert expect(wrapper.find("img")).toBeTruthy(); @@ -19,7 +19,8 @@ describe("funnelHeader", () => { }); }); -//Mock CMS content -const cmsContent = { - imageSrc: "image_url", -}; +const mockMixin = { + methods: { + getCmsContent: jest.fn() + } +} diff --git a/src/common-components/funnel-sub-header/funnel-sub-header.spec.js b/src/common-components/funnel-sub-header/funnel-sub-header.spec.js index 08561ce67..ebcb9ca91 100644 --- a/src/common-components/funnel-sub-header/funnel-sub-header.spec.js +++ b/src/common-components/funnel-sub-header/funnel-sub-header.spec.js @@ -4,19 +4,18 @@ import FunnelSubHeader from "./funnel-sub-header"; describe("FunnelSubHeader.vue", () => { it("Should render the 'text' data value as a span value for the header span text value.", async () => { // Act - const wrapper = shallowMount(FunnelSubHeader); - await wrapper.setData({ - text: "FunnelSubHeader Content", + const wrapper = shallowMount(FunnelSubHeader, { + mixins: [mockMixin] }); - wrapper.vm.initializeComponent(cmsContent); + wrapper.vm.clickEvent(); // Assert - expect(wrapper.find("h5").text()).toContain("FunnelSubHeader Content"); - wrapper.unmount(); + expect(wrapper.emitted()).toEqual({"click-event": [[]]}); }); }); -//Mock CMS content -const cmsContent = { - HeaderText: "FunnelSubHeader Content", -}; +const mockMixin = { + methods: { + getCmsContent: jest.fn() + } +} diff --git a/src/common-components/funnel-sub-header/funnel-sub-header.vue b/src/common-components/funnel-sub-header/funnel-sub-header.vue index 0799e4744..155203e65 100644 --- a/src/common-components/funnel-sub-header/funnel-sub-header.vue +++ b/src/common-components/funnel-sub-header/funnel-sub-header.vue @@ -1,7 +1,7 @@