From 9023c7d215ed89099462582b0ac144a5c4b3fc42 Mon Sep 17 00:00:00 2001 From: Leah Schumann Date: Mon, 6 Mar 2023 10:31:40 -0500 Subject: [PATCH] Fixed unit tests after merge --- jest.config.js | 1 + .../service-location/service-location.spec.js | 69 +++++++++++++++++++ .../service-location/service-location.vue | 17 ----- 3 files changed, 70 insertions(+), 17 deletions(-) diff --git a/jest.config.js b/jest.config.js index bfb4bf71f..4d8fd76b1 100644 --- a/jest.config.js +++ b/jest.config.js @@ -27,4 +27,5 @@ module.exports = { // Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90 }, }, + silent: true }; diff --git a/src/layouts/service-location/service-location.spec.js b/src/layouts/service-location/service-location.spec.js index d60de2603..0554f4952 100644 --- a/src/layouts/service-location/service-location.spec.js +++ b/src/layouts/service-location/service-location.spec.js @@ -43,6 +43,75 @@ jest.mock("@/store", () => ({ dispatch: jest.fn(), })); +const mockMixin = { + methods: { + getCmsContent: jest.fn((widgetName, cmsFieldName) => { + if (widgetName === linkWidgetName) { + return mockLinkCmsContent[cmsFieldName]; + } + + if (widgetName === modalWidgetName) { + return mockModalCmsContent[cmsFieldName]; + } + + if (widgetName === mobileFeeDisclaimerWidgetName) { + return mockMobileFeeDisclaimerContent[cmsFieldName]; + } + + return null; + }), + + getZipCodeData: jest.fn((zip) => { + if (zip === "43235" || zip === "55555") { + return Promise.resolve({ + containsMilitaryBase: false, + isServiceable: true, + isValid: true, + state: "OH", + zipCodeCtu: "01820", + }); + } + + return Promise.resolve({ + containsMilitaryBase: false, + isServiceable: false, + isValid: false, + state: null, + zipCodeCtu: null, + }); + }), + + dispatchStoreAction: jest.fn((actionName) => { + if (actionName === storeActions.GET_MOBILE_FEE_PART) { + return Promise.resolve({ + data: { + partNumber: "MOBILE FEE", + description: "MOBILE FEE", + partType: "FEE", + }, + }); + } + + if (actionName === storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA) { + return Promise.resolve([ + { + partNumber: "MOBILE FEE", + description: "MOBILE FEE", + partType: "FEE", + laborAmount: 49.99, + sellingPrice: 0, + kitPrice: 0, + }, + ]); + } + }), + + getTotalLineItemPrice: jest.fn((lineItem) => { + return 49.99; + }), + }, +}; + beforeEach(() => { store.getters = { lineItems: { diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index dafe9a3dd..11cf42daa 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -137,23 +137,6 @@ export default { this.mobileFeePart = newValue.mobileFeePart; }, }, - mobileLocationLinkPromptText() { - return this.getCmsContent("MobileLocationLinkWidget", "HeaderText"); - }, - mobileFeeDisclaimerText() { - const cmsContentText = this.getCmsContent("MobileFeeDisclaimerWidget", "Text"); - return cmsContentText.replaceAll("{custom:mobileFee}", this.mobileFee); - }, - mobileFee() { - if (!this.mobileFeePart) { - return 0; - } - return ( - this.mobileFeePart.laborAmount + - this.mobileFeePart.sellingPrice + - this.mobileFeePart.kitPrice - ); - }, }, methods: { arePagePrerequisitesValid() {