Added .spec file for mobile-location-question
This commit is contained in:
parent
07a54cbf29
commit
fbbb92c855
2 changed files with 111 additions and 14 deletions
|
|
@ -0,0 +1,98 @@
|
||||||
|
import { mount, shallowMount } from "@vue/test-utils";
|
||||||
|
import mobileLocationModalQuestions from "./mobile-location-modal-questions";
|
||||||
|
import crypto from "crypto";
|
||||||
|
global.crypto = crypto;
|
||||||
|
|
||||||
|
// const linkWidgetName = "linkWidgetName";
|
||||||
|
// const modalWidgetName = "modalWidgetName";
|
||||||
|
// const mobileFeeDisclaimerWidgetName = "MobileFeeDisclaimerWidget";
|
||||||
|
// const workspaceRequirementsWidgetName = "WorkspaceRequirementsWidget";
|
||||||
|
|
||||||
|
// const mockLinkCmsContent = {
|
||||||
|
// BodyText: "Sample link body text here.",
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const mockModalCmsContent = {
|
||||||
|
// FooterText: "Sample modal footer text here.",
|
||||||
|
// };
|
||||||
|
|
||||||
|
// const mockMobileFeeCmsContent = {
|
||||||
|
// Text: "This is the price {custom:mobileFee}",
|
||||||
|
// };
|
||||||
|
|
||||||
|
const mockMixin = {
|
||||||
|
methods: {
|
||||||
|
getCmsContent: jest.fn((widgetName, cmsFieldName) => {
|
||||||
|
if (widgetName === linkWidgetName) {
|
||||||
|
return mockLinkCmsContent[cmsFieldName];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widgetName === modalWidgetName) {
|
||||||
|
return mockModalCmsContent[cmsFieldName];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widgetName === mobileFeeDisclaimerWidgetName) {
|
||||||
|
return mockMobileFeeCmsContent[cmsFieldName];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}),
|
||||||
|
|
||||||
|
getZipCodeData: jest.fn((zip) => {
|
||||||
|
if (zip === "43235") {
|
||||||
|
return {
|
||||||
|
containsMilitaryBase: false,
|
||||||
|
isServiceable: true,
|
||||||
|
isValid: true,
|
||||||
|
state: "OH",
|
||||||
|
zipCodeCtu: "01820",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zip === "61606") {
|
||||||
|
return {
|
||||||
|
containsMilitaryBase: false,
|
||||||
|
isServiceable: true,
|
||||||
|
isValid: true,
|
||||||
|
state: "IL",
|
||||||
|
zipCodeCtu: "01526",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
containsMilitaryBase: false,
|
||||||
|
isServiceable: false,
|
||||||
|
isValid: false,
|
||||||
|
state: null,
|
||||||
|
zipCodeCtu: null,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("mobile-location-modal-questions.vue", () => {
|
||||||
|
it("Initial state on load with no existing location info", async () => {
|
||||||
|
let mobileLocationQuestions = {
|
||||||
|
addressQuestions: {
|
||||||
|
streetAddress: "",
|
||||||
|
apartmentNumberOrBusinessName: "",
|
||||||
|
city: "",
|
||||||
|
state: "",
|
||||||
|
zipCode: "",
|
||||||
|
},
|
||||||
|
isVehicleProtected: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Arrange
|
||||||
|
const wrapper = shallowMount(mobileLocationModalQuestions, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
modelValue: mobileLocationQuestions,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
//expect(wrapper.html()).toEqual(expect.stringContaining(mockLinkCmsContent["BodyText"]));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -11,20 +11,20 @@ const mockMixin = {
|
||||||
if (cmsFieldName === "Answers") {
|
if (cmsFieldName === "Answers") {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
"AnswerImageUrl": "",
|
AnswerImageUrl: "",
|
||||||
"Name": "YesAnswer",
|
Name: "YesAnswer",
|
||||||
"SubText": "",
|
SubText: "",
|
||||||
"SubWidgetName": "",
|
SubWidgetName: "",
|
||||||
"Text": "Yes"
|
Text: "Yes",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"AnswerImageUrl": "",
|
AnswerImageUrl: "",
|
||||||
"Name": "NoAnswer",
|
Name: "NoAnswer",
|
||||||
"SubText": "",
|
SubText: "",
|
||||||
"SubWidgetName": "",
|
SubWidgetName: "",
|
||||||
"Text": "No"
|
Text: "No",
|
||||||
}
|
},
|
||||||
]
|
];
|
||||||
}
|
}
|
||||||
return "QuestionText";
|
return "QuestionText";
|
||||||
}),
|
}),
|
||||||
|
|
@ -48,13 +48,12 @@ describe("service-zip-question.vue", () => {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(modelValueAnswer).toEqual(answer);
|
expect(modelValueAnswer).toEqual(answer);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should emit to set value", async () => {
|
it("Should emit to set value", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const yesAnswer = "YesAnswer";
|
const yesAnswer = "YesAnswer";
|
||||||
const noAnswer = "NoAnswer"
|
const noAnswer = "NoAnswer";
|
||||||
const wrapper = shallowMount(vehicleProtectedQuestion, {
|
const wrapper = shallowMount(vehicleProtectedQuestion, {
|
||||||
mixins: [mockMixin],
|
mixins: [mockMixin],
|
||||||
props: {
|
props: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue