From b1efd351a05351c07eca5c52f6b2fd471962f52c Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Wed, 14 Dec 2022 10:22:10 -0500 Subject: [PATCH] modal component. --- src/common-components/modal/modal.spec.js | 68 +++++++++++ src/common-components/modal/modal.vue | 133 ++++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 src/common-components/modal/modal.spec.js create mode 100644 src/common-components/modal/modal.vue diff --git a/src/common-components/modal/modal.spec.js b/src/common-components/modal/modal.spec.js new file mode 100644 index 00000000..2664accf --- /dev/null +++ b/src/common-components/modal/modal.spec.js @@ -0,0 +1,68 @@ +import { shallowMount } from "@vue/test-utils"; +import Modal from "./modal"; + +describe("modal.vue", () => { + it("Should display header text when HeaderText is defined in the CMS", async () => { + // Act + const wrapper = shallowMount(Modal, { + mixins: [mockMixin], + props: { + cmsWidgetName: "test", + }, + attachTo: document.body, + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent["HeaderText"])); + }); + + it("Should display subheader text when SubheaderText is defined in the CMS", async () => { + // Act + const wrapper = shallowMount(Modal, { + mixins: [mockMixin], + props: { + cmsWidgetName: "test", + }, + attachTo: document.body, + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent["SubheaderText"])); + }); + + it("Should insert image url when Image is defined in the CMS", async () => { + // Act + const wrapper = shallowMount(Modal, { + mixins: [mockMixin], + props: { + cmsWidgetName: "test", + }, + attachTo: document.body, + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent["Image"])); + }); + + it("Should display body text when BodyText is defined in the CMS", async () => { + // Act + const wrapper = shallowMount(Modal, { + mixins: [mockMixin], + props: { + cmsWidgetName: "test", + }, + attachTo: document.body, + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent["BodyText"])); + }); +}); + +const mockMixin = { + methods: { + getCmsContent: jest.fn((widgetName, cmsFieldName) => { + return mockCmsContent[cmsFieldName]; + }), + }, +}; + +const mockCmsContent = { + HeaderText: "Sample header text here.", + SubheaderText: "Sample subheader text here.", + Image: "https://www.sampleImage.sample", + BodyText: "Sample body text here.", + FooterText: "Sample footer text here.", +}; diff --git a/src/common-components/modal/modal.vue b/src/common-components/modal/modal.vue new file mode 100644 index 00000000..9845e089 --- /dev/null +++ b/src/common-components/modal/modal.vue @@ -0,0 +1,133 @@ + + + + +