Fixed unit tests
This commit is contained in:
parent
f89705c7a1
commit
0d5231ff87
4 changed files with 56 additions and 1 deletions
|
|
@ -93,6 +93,32 @@ const mockMixin = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockGetPricedMobileFeePart = (mockServiceZipCode) => {
|
||||||
|
let mobileFeePart = {};
|
||||||
|
|
||||||
|
if (mockServiceZipCode === "43235") {
|
||||||
|
mobileFeePart = {
|
||||||
|
partNumber: "MOBILE FEE",
|
||||||
|
description: "MOBILE FEE",
|
||||||
|
partType: "FEE",
|
||||||
|
laborAmount: 49.99,
|
||||||
|
sellingPrice: 0,
|
||||||
|
kitPrice: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve(mobileFeePart);
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.mock(
|
||||||
|
"@/layouts/service-location/helpers/service-location-helper/service-location-helper",
|
||||||
|
() => ({
|
||||||
|
getPricedMobileFeePart: jest.fn((mockServiceZipCode) => {
|
||||||
|
return mockGetPricedMobileFeePart(mockServiceZipCode);
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
describe("mobile-location-modal-questions.vue", () => {
|
describe("mobile-location-modal-questions.vue", () => {
|
||||||
it("Should copy the modelValue to the internalModel when the component is mounted", async () => {
|
it("Should copy the modelValue to the internalModel when the component is mounted", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ import { getPricedMobileFeePart } from "@/layouts/service-location/helpers/servi
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "mobile-location-modal-questions",
|
name: "mobile-location-modal-questions",
|
||||||
emits: ["update:modelValue"], // The component emits an event
|
emits: ["update:modelValue", "set-mobile-fee-part"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
internalModel: deepClone(this.modelValue),
|
internalModel: deepClone(this.modelValue),
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,32 @@ jest.mock("@/digital-components/modal/modal", () => ({
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const mockGetPricedMobileFeePart = (mockServiceZipCode) => {
|
||||||
|
let mobileFeePart = {};
|
||||||
|
|
||||||
|
if (mockServiceZipCode === "43235") {
|
||||||
|
mobileFeePart = {
|
||||||
|
partNumber: "MOBILE FEE",
|
||||||
|
description: "MOBILE FEE",
|
||||||
|
partType: "FEE",
|
||||||
|
laborAmount: 49.99,
|
||||||
|
sellingPrice: 0,
|
||||||
|
kitPrice: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.resolve(mobileFeePart);
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.mock(
|
||||||
|
"@/layouts/service-location/helpers/service-location-helper/service-location-helper",
|
||||||
|
() => ({
|
||||||
|
getPricedMobileFeePart: jest.fn((mockServiceZipCode) => {
|
||||||
|
return mockGetPricedMobileFeePart(mockServiceZipCode);
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const linkWidgetName = "linkWidgetName";
|
const linkWidgetName = "linkWidgetName";
|
||||||
const modalWidgetName = "modalWidgetName";
|
const modalWidgetName = "modalWidgetName";
|
||||||
|
|
||||||
|
|
@ -126,6 +152,7 @@ describe("service-zip-modal-question.vue", () => {
|
||||||
mixins: [mockMixin],
|
mixins: [mockMixin],
|
||||||
props: {
|
props: {
|
||||||
modelValue: serviceZipCodeQuestion,
|
modelValue: serviceZipCodeQuestion,
|
||||||
|
mobileFeePart: {},
|
||||||
linkWidgetName: linkWidgetName,
|
linkWidgetName: linkWidgetName,
|
||||||
modalWidgetName: modalWidgetName,
|
modalWidgetName: modalWidgetName,
|
||||||
},
|
},
|
||||||
|
|
@ -134,6 +161,7 @@ describe("service-zip-modal-question.vue", () => {
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.internalModel.zipCode = zip;
|
wrapper.vm.internalModel.zipCode = zip;
|
||||||
|
|
||||||
await wrapper.vm.setZipCode();
|
await wrapper.vm.setZipCode();
|
||||||
|
|
||||||
let expectedEmit = [[{ state: "OH", zipCode: "43235" }]];
|
let expectedEmit = [[{ state: "OH", zipCode: "43235" }]];
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ import { getPricedMobileFeePart } from "@/layouts/service-location/helpers/servi
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "service-zip-modal-question",
|
name: "service-zip-modal-question",
|
||||||
|
emits: ["update:modelValue", "set-mobile-fee-part"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
internalModel: this.copyModel(this.modelValue),
|
internalModel: this.copyModel(this.modelValue),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue