diff --git a/src/layouts/payment-method/payment-method-question/payment-method-question.spec.js b/src/layouts/payment-method/payment-method-question/payment-method-question.spec.js index 97194f10..6d671280 100644 --- a/src/layouts/payment-method/payment-method-question/payment-method-question.spec.js +++ b/src/layouts/payment-method/payment-method-question/payment-method-question.spec.js @@ -2,6 +2,7 @@ import { shallowMount } from '@vue/test-utils'; import { getMountOptions } from '@/helpers/unit-test-helper.js'; import widgetFields from '@/constants/cms-widget-fields.js'; import paymentMethodQuestion from '@/layouts/payment-method/payment-method-question/payment-method-question.vue'; +import baseMixin from '@/mixins/base-mixin'; let cmsContent; @@ -39,6 +40,7 @@ function setupMocks(customMountOptions) { const mockMixin = { methods: { + ...baseMixin.methods, getCmsContent: jest.fn((widgetName, cmsFieldName) => cmsContent[cmsFieldName]) } }; diff --git a/src/layouts/payment-method/review-dropdown/review-sections/damage-review/damage-review.spec.js b/src/layouts/payment-method/review-dropdown/review-sections/damage-review/damage-review.spec.js index 5e369a72..1d5ec7b7 100644 --- a/src/layouts/payment-method/review-dropdown/review-sections/damage-review/damage-review.spec.js +++ b/src/layouts/payment-method/review-dropdown/review-sections/damage-review/damage-review.spec.js @@ -7,6 +7,7 @@ import { useMainStore } from '@/store'; import { shallowMount } from '@vue/test-utils'; import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { getDamageDisplayContent } from '@/helpers/damage-review-content-generator.js'; +import baseMixin from '@/mixins/base-mixin'; jest.mock('@/helpers/damage-review-content-generator.js', () => ({ getDamageDisplayContent: jest.fn(), @@ -16,6 +17,7 @@ jest.mock('@/helpers/damage-review-content-generator.js', () => ({ let cmsContent; const mockMixin = { methods: { + ...baseMixin.methods, getCmsContent: jest.fn((widgetName, cmsFieldName) => cmsContent?.[widgetName]?.[cmsFieldName] ?? '') } }; diff --git a/src/layouts/tpa-submit/tpa-submit.spec.js b/src/layouts/tpa-submit/tpa-submit.spec.js index 53ad8b54..aaadc048 100644 --- a/src/layouts/tpa-submit/tpa-submit.spec.js +++ b/src/layouts/tpa-submit/tpa-submit.spec.js @@ -11,6 +11,7 @@ import settleAllPromises from '@/helpers/layout-helper.js'; import widgetFields from '@/constants/cms-widget-fields.js'; import { toTitleCase, formatAddress, toDisplayPhoneNumber } from '@/helpers/text-helper.js'; import { getDamageDisplayContent } from '@/helpers/damage-review-content-generator.js'; +import baseMixin from '@/mixins/base-mixin'; // Mock fetchCmsContentForPage jest.mock('@/helpers/cms-content-helper', () => ({ @@ -35,6 +36,12 @@ jest.mock('@/helpers/damage-review-content-generator.js', () => ({ // Mock our module for promises. jest.mock('@/helpers/layout-helper.js', () => jest.fn()); +const mockMixin = { + methods: { + ...baseMixin.methods + } +}; + function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRunAfterInitializingStore = () => {}) { const mountOptions = getMountOptions({ router: { @@ -52,6 +59,7 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu mountOptions.global.plugins = [testingPinia]; mountOptions.data = () => (initialData); + mountOptions.mixins = [mockMixin]; const apiResponses = { cmsContent: {} }; @@ -775,14 +783,14 @@ describe('tpa-submit', () => { [[], []], [undefined, []], [null, []] - ])('getAnswersNullSafe', (rawAnswers, expected) => { + ])('getInputQuestionWidgetAnswersNullSafe', (rawAnswers, expected) => { // Arrange const widgetName = 'WidgetName'; const { wrapper } = getMountedComponent(); wrapper.vm.getCmsContent = jest.fn().mockImplementationOnce(() => rawAnswers); // Act - const result = wrapper.vm.getAnswersNullSafe(widgetName); + const result = wrapper.vm.getInputQuestionWidgetAnswersNullSafe(widgetName); // Assert expect(result).toEqual(expected);