From a5b8ecba241b096dad13e0ac373898a42f1ac9f3 Mon Sep 17 00:00:00 2001 From: Kulbhushan Kaushik Date: Wed, 4 Jan 2023 14:46:07 -0500 Subject: [PATCH] commit --- .../text-block/text-block.spec.js | 59 +++++++++++++++++++ .../text-block/text-block.vue | 40 +++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 src/common-components/text-block/text-block.spec.js create mode 100644 src/common-components/text-block/text-block.vue diff --git a/src/common-components/text-block/text-block.spec.js b/src/common-components/text-block/text-block.spec.js new file mode 100644 index 00000000..3cd22944 --- /dev/null +++ b/src/common-components/text-block/text-block.spec.js @@ -0,0 +1,59 @@ +import { shallowMount } from "@vue/test-utils"; +import TextBlock from "./text-block"; + +describe("modal.vue", () => { + it("Should display 'Text' when 'Text' is defined in the CMS", async () => { + // Act + const wrapper = shallowMount(TextBlock, { + mixins: [mockMixin], + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent["Text"])); + }); + + it("Should contain the typeStyle class as defined by the prop", async () => { + // Act + const wrapper = shallowMount(TextBlock, { + mixins: [mockMixin], + propsData: mockProps, + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockProps["typeStyle"])); + }); + it("Should contain the justifyText class as defined by the prop", async () => { + // Act + const wrapper = shallowMount(TextBlock, { + mixins: [mockMixin], + propsData: mockProps, + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockProps["justifyText"])); + }); + it("Should contain the fontWeight class as defined by the prop", async () => { + // Act + const wrapper = shallowMount(TextBlock, { + mixins: [mockMixin], + propsData: mockProps, + }); + expect(wrapper.html()).toEqual(expect.stringContaining(mockProps["fontWeight"])); + }); +}); + +/////////////// +// Constants // +/////////////// + +const mockMixin = { + methods: { + getCmsContent: jest.fn((widgetName, cmsFieldName) => { + return mockCmsContent[cmsFieldName]; + }), + }, +}; + +const mockProps = { + fontWeight: "mockFontWeight", + typeStyle: "mockTypeStyle", + justifyText: "mockJustifyText", +}; + +const mockCmsContent = { + Text: "Sample text here.", +}; diff --git a/src/common-components/text-block/text-block.vue b/src/common-components/text-block/text-block.vue new file mode 100644 index 00000000..a12d3f39 --- /dev/null +++ b/src/common-components/text-block/text-block.vue @@ -0,0 +1,40 @@ + + + + +