CSR-1012 some unit tests for service-location-modal-question
This commit is contained in:
parent
ac99ddfbb4
commit
1fccadd678
1 changed files with 79 additions and 1 deletions
|
|
@ -1,3 +1,81 @@
|
||||||
|
import { mount } from "@vue/test-utils";
|
||||||
|
import serviceZipModalQuestion from "./service-zip-modal-question";
|
||||||
|
import crypto from "crypto";
|
||||||
|
global.crypto = crypto;
|
||||||
|
|
||||||
|
jest.mock('@/digital-components/textbox-question/textbox-question', () => ({
|
||||||
|
getCmsContent: jest.fn((widgetName, cmsFieldName) => {
|
||||||
|
return widgetName[cmsFieldName];
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const linkWidgetName = "linkWidgetName";
|
||||||
|
const modalWidgetName = "modalWidgetName";
|
||||||
|
const textboxQuestionWidgetName = "textboxQuestionWidgetName";
|
||||||
|
|
||||||
|
const mockLinkCmsContent = {
|
||||||
|
BodyText: "Sample link body text here.",
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockModalCmsContent = {
|
||||||
|
FooterText: "Sample modal footer text here.",
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTextboxQuestionCmsContent = {
|
||||||
|
QuestionText: "Sample question text here."
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockMixin = {
|
||||||
|
methods: {
|
||||||
|
getCmsContent: jest.fn((widgetName, cmsFieldName) => {
|
||||||
|
if (widgetName === linkWidgetName)
|
||||||
|
return mockLinkCmsContent[cmsFieldName];
|
||||||
|
|
||||||
|
if (widgetName === modalWidgetName)
|
||||||
|
return mockModalCmsContent[cmsFieldName];
|
||||||
|
|
||||||
|
if (widgetName === textboxQuestionWidgetName)
|
||||||
|
return mockTextboxQuestionCmsContent[cmsFieldName];
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}),
|
||||||
|
|
||||||
|
getZipCodeData: jest.fn((zip) => {
|
||||||
|
return {
|
||||||
|
isValid: true,
|
||||||
|
state: "OH",
|
||||||
|
isServiceable: true,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
describe("service-zip-modal-question.vue", () => {
|
describe("service-zip-modal-question.vue", () => {
|
||||||
test.todo("test this");
|
|
||||||
|
it("Should display text from textboxQuestionWidget", async () => {
|
||||||
|
const wrapper = mount(serviceZipModalQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
linkWidgetName: linkWidgetName,
|
||||||
|
modalWidgetName: modalWidgetName,
|
||||||
|
textboxQuestionWidgetName: textboxQuestionWidgetName,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
expect(wrapper.html()).toEqual(expect.stringContaining(mockTextboxQuestionCmsContent["QuestionText"]));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should display footer text from modalWidget", async () => {
|
||||||
|
const wrapper = mount(serviceZipModalQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
linkWidgetName: linkWidgetName,
|
||||||
|
modalWidgetName: modalWidgetName,
|
||||||
|
textboxQuestionWidgetName: textboxQuestionWidgetName,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
expect(wrapper.html()).toEqual(expect.stringContaining(mockModalCmsContent["FooterText"]));
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue