FIx failing tests, add new test case
This commit is contained in:
parent
345f338f1a
commit
a191779147
1 changed files with 33 additions and 1 deletions
|
|
@ -13,6 +13,7 @@ import errorMessages from '@/constants/error-messages';
|
||||||
import globalRules from '@/constants/global-rules';
|
import globalRules from '@/constants/global-rules';
|
||||||
import { required } from '@/helpers/validation-rules';
|
import { required } from '@/helpers/validation-rules';
|
||||||
import VehicleLookup from '@/layouts/vehicle-lookup/vehicle-lookup.vue';
|
import VehicleLookup from '@/layouts/vehicle-lookup/vehicle-lookup.vue';
|
||||||
|
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
|
||||||
|
|
||||||
const pinia = createTestingPinia();
|
const pinia = createTestingPinia();
|
||||||
useMainStore(pinia);
|
useMainStore(pinia);
|
||||||
|
|
@ -40,6 +41,13 @@ const vinLookupMethodsMockData = {
|
||||||
SubText: 'Most convenient VIN match',
|
SubText: 'Most convenient VIN match',
|
||||||
ImageId: '',
|
ImageId: '',
|
||||||
SubWidgetName: ''
|
SubWidgetName: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: 'NoVin',
|
||||||
|
Text: 'I\'d prefer not to share my VIN',
|
||||||
|
SubText: '',
|
||||||
|
ImageId: '',
|
||||||
|
SubWidgetName: ''
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
@ -118,7 +126,8 @@ function setupMocks() {
|
||||||
},
|
},
|
||||||
stubs: {
|
stubs: {
|
||||||
SiteHeader: true,
|
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.
|
* 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
|
* To Do: Error message is not displayed when running test
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue