CSR-795 | Added unit tests to modal.vue

This commit is contained in:
Scott Kiener 2022-09-01 10:55:21 -04:00
parent fcf95ad734
commit 5c9d7dc53c
2 changed files with 61 additions and 2 deletions

View file

@ -0,0 +1,61 @@
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]
});
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]
});
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]
});
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]
});
expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent['BodyText']));
});
it("Should display footer text when FooterText is defined in the CMS", async () => {
// Act
const wrapper = shallowMount(Modal, {
mixins: [mockMixin]
});
expect(wrapper.html()).toEqual(expect.stringContaining(mockCmsContent['FooterText']));
});
});
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.",
}

View file

@ -18,11 +18,9 @@
</template>
<script>
import textLink from "@/ux-components/text-link/text-link";
export default {
name: 'modal',
props: {
headlineText: String,
cmsWidgetName: String,
},
data() {