From c249e4b8339d5f9d14d35d46f0f3d459b500c538 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Thu, 15 Aug 2024 15:28:38 -0400 Subject: [PATCH] Actually done --- .../order-confirmation.spec.js | 83 +++++++++++-------- .../order-confirmation/order-confirmation.vue | 2 +- 2 files changed, 49 insertions(+), 36 deletions(-) diff --git a/src/layouts/order-confirmation/order-confirmation.spec.js b/src/layouts/order-confirmation/order-confirmation.spec.js index 504beb2d..e0f651c6 100644 --- a/src/layouts/order-confirmation/order-confirmation.spec.js +++ b/src/layouts/order-confirmation/order-confirmation.spec.js @@ -25,7 +25,7 @@ jest.mock('@/helpers/cms-content-helper', () => ({ const mockMixin = { methods: { - getCmsContent: jest.fn(),//.mockImplementation(() => wordingText), + getCmsContent: jest.fn(), setCmsContent: jest.fn() } }; @@ -178,6 +178,9 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu } describe('OrderConfirmation.vue', () => { + afterEach(() => { + jest.resetAllMocks(); + }) describe('Page pre-requisites', () => { test('If submitted order saved to store, page pre-reqs return true', async () => { // Arrange @@ -282,7 +285,7 @@ describe('OrderConfirmation.vue', () => { expect(wrapper.vm.$router.navigateToExternalUrl).toHaveBeenCalledWith(carrierReturnUrl); }); }); - describe.only('Computed properties', () => { + describe('Computed properties', () => { describe('customValueMap', () =>{ test.each([ 'inShopAppointment', @@ -352,6 +355,10 @@ describe('OrderConfirmation.vue', () => { describe('confirmationEmailText', () => { const greaterId = ">"; const lessId = "<"; + const mobileWording = "Mobile wording"; + const nonMobileWording = "Non mobile wording"; + const mobileWidget = "MobileWordingWidget"; + const dropOffAndInShopWidget = "DropOffAndInShopWordingWidget" test.each([ ['test', 'test'], [`te${greaterId}st`, 'te>st'], @@ -365,7 +372,7 @@ describe('OrderConfirmation.vue', () => { const mockStoreActions = () => { useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => sessionStorage); }; - getStringWithCustomValues.mockImplementation(() => rawCms); + getStringWithCustomValues.mockReturnValue(rawCms); const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions); // Act @@ -750,22 +757,25 @@ describe('OrderConfirmation.vue', () => { const nonMobileWording = "Non mobile wording"; const mobileWidget = "MobileWordingWidget"; const dropOffAndInShopWidget = "DropOffAndInShopWordingWidget" - const mixin = { - methods: { - getCmsContent: jest.fn().mockImplementation((widget, _) => { - if (widget == mobileWidget){ - return mobileWording; - } - if (widget == dropOffAndInShopWidget){ - return nonMobileWording; - } - return ""; - }), - setCmsContent: jest.fn() - } - }; - processIfStatements.mockImplementation((content) => content); - getStringWithCustomValues.mockImplementation((content, _) => content); + let mixin; + beforeEach(() => { + processIfStatements.mockImplementation((content) => content); + getStringWithCustomValues.mockImplementation((content, _) => content); + mixin = { + methods: { + getCmsContent: jest.fn().mockImplementation((widget, _) => { + if (widget == mobileWidget){ + return mobileWording; + } + if (widget == dropOffAndInShopWidget){ + return nonMobileWording; + } + return ""; + }), + setCmsContent: jest.fn() + } + }; + }); test.each([ [AppointmentTypeStrings.MOBILE, mobileWording], [AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP, mobileWording], @@ -796,22 +806,25 @@ describe('OrderConfirmation.vue', () => { const nonMobileWording = "Non mobile wording"; const mobileWidget = "MobileWordingWidget"; const dropOffAndInShopWidget = "DropOffAndInShopWordingWidget" - const mixin = { - methods: { - getCmsContent: jest.fn().mockImplementation((widget, _) => { - if (widget == mobileWidget){ - return mobileWording; - } - if (widget == dropOffAndInShopWidget){ - return nonMobileWording; - } - return ""; - }), - setCmsContent: jest.fn() - } - }; - processIfStatements.mockImplementation((content) => content); - getStringWithCustomValues.mockImplementation((content, _) => content); + let mixin; + beforeEach(() => { + processIfStatements.mockImplementation((content) => content); + getStringWithCustomValues.mockImplementation((content, _) => content); + mixin = { + methods: { + getCmsContent: jest.fn().mockImplementation((widget, _) => { + if (widget == mobileWidget){ + return mobileWording; + } + if (widget == dropOffAndInShopWidget){ + return nonMobileWording; + } + return ""; + }), + setCmsContent: jest.fn() + } + }; + }); test.each([ [AppointmentTypeStrings.MOBILE, mobileWording], [AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP, mobileWording], diff --git a/src/layouts/order-confirmation/order-confirmation.vue b/src/layouts/order-confirmation/order-confirmation.vue index 60182e7a..b824e266 100644 --- a/src/layouts/order-confirmation/order-confirmation.vue +++ b/src/layouts/order-confirmation/order-confirmation.vue @@ -257,7 +257,7 @@ export default { providerFullAddress() { var { streetAddress, city, state, zipCode } = this.providerAddress; return streetAddress - ? `${toTitleCase(streetAddress)},
${toTitleCase(city)}, ${state} ${zipCode}` + ? `${toTitleCase(streetAddress)},
${toTitleCase(city)}, ${state ?? ''} ${zipCode ?? ''}` : ''; }, appointmentWordingText() {