From c4a69a273c30998047b7e743e0c1de6216d92b7c Mon Sep 17 00:00:00 2001 From: Kroell Date: Wed, 8 Mar 2023 16:15:40 -0500 Subject: [PATCH] unit tests for recal modal --- .../recal-modal/recal-modal.spec.js | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/layouts/coverage-statement/recal-modal/recal-modal.spec.js diff --git a/src/layouts/coverage-statement/recal-modal/recal-modal.spec.js b/src/layouts/coverage-statement/recal-modal/recal-modal.spec.js new file mode 100644 index 00000000..3ab73b9a --- /dev/null +++ b/src/layouts/coverage-statement/recal-modal/recal-modal.spec.js @@ -0,0 +1,68 @@ +import { shallowMount } from "@vue/test-utils"; +import recalModal from "@/layouts/coverage-statement/recal-modal/recal-modal.vue"; + +describe("modal.vue", () => { + it("Should display header text when HeaderText is defined in the CMS", async () => { + // Act + const wrapper = shallowMount(recalModal, { + 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(recalModal, { + 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(recalModal, { + 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(recalModal, { + 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.", +};