diff --git a/src/layouts/vehicle-lookup/vehicle-lookup.spec.js b/src/layouts/vehicle-lookup/vehicle-lookup.spec.js index 0aa12f8a..300b656d 100644 --- a/src/layouts/vehicle-lookup/vehicle-lookup.spec.js +++ b/src/layouts/vehicle-lookup/vehicle-lookup.spec.js @@ -13,6 +13,7 @@ import errorMessages from '@/constants/error-messages'; import globalRules from '@/constants/global-rules'; import { required } from '@/helpers/validation-rules'; import VehicleLookup from '@/layouts/vehicle-lookup/vehicle-lookup.vue'; +import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin'; const pinia = createTestingPinia(); useMainStore(pinia); @@ -40,6 +41,13 @@ const vinLookupMethodsMockData = { SubText: 'Most convenient VIN match', ImageId: '', SubWidgetName: '' + }, + { + Name: 'NoVin', + Text: 'I\'d prefer not to share my VIN', + SubText: '', + ImageId: '', + SubWidgetName: '' } ] }; @@ -118,7 +126,8 @@ function setupMocks() { }, stubs: { SiteHeader: true, - SiteSubHeader: true + SiteSubHeader: true, + TextBlock: true } } }); @@ -264,6 +273,29 @@ describe('vehicle-lookup.vue', () => { * Currently just trust that our custom navigate() method does its job properly. */ }); + + test('Select "I\'d prefer not to share my VIN" then click "Continue". Calls navigateForward from vehicleQuestionsMixin', async () => { + useMainStore().getPartsOrQuestions = () => ({ data: { partsOrQuestions: [] } }); + navigateSpy = jest.spyOn(vehicleQuestionsMixin.methods, 'navigateForward').mockImplementation(async () => {}); + const { wrapper } = setupMocks(); + + const vinLookupMethodsWrapper = wrapper.findComponent({ name: 'vin-lookup-methods' }); + // Not using initializeComponent() because it doesn't trigger reactivity in test. + await vinLookupMethodsWrapper.setData({ + questionTextFromCms: vinLookupMethodsMockData.QuestionText, + answersFromCms: vinLookupMethodsMockData.Answers + }); + + const noVinOptionLabel = wrapper + .find('[data-test-id="vin-lookup-methods-button-question"] label[for="VinLookupMethods-NoVin"]'); + await noVinOptionLabel.trigger('mousedown'); + + const continueButton = wrapper.get('[data-test-id="site-footer-main-button"]'); + await continueButton.trigger('click'); + + // Assert + expect(navigateSpy).toHaveBeenCalled(); + }); /** * To Do: Error message is not displayed when running test