completed unit test

This commit is contained in:
Katie Kroell 2024-04-23 14:43:27 -04:00
parent 647c47c86a
commit ee08bed3ea
2 changed files with 15 additions and 13 deletions

View file

@ -122,14 +122,7 @@ const vehicleWithNoAdditionalPartsOrQuestionsMockResponse = {
};
const partsOrQuestionsErrorMockResponse = {
data: {
partsOrQuestions: [
{
parts: null
}
],
partQuestions: null
}
error: 'Error getting parts'
};
jest.mock('bootstrap', () => ({
@ -533,6 +526,14 @@ describe('vin-lookup.vue', () => {
async () => {
const user = userEvent.setup();
mountOptions.global.stubs.vinQuestion = false;
mountOptions.data = () => ({
vinWithNonMatchingCarId: false,
isCarIdDifferentFromTheStore: false,
vin: mockValidVin,
hasBailedOut: true
});
getPartsOrQuestions.mockResponse = partsOrQuestionsErrorMockResponse;
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)

View file

@ -151,6 +151,9 @@ export default {
carIdIsValid() {
return this.hasValidCarId();
},
hasBailedOut() {
return false;
}
},
watch: {
vin() {
@ -274,14 +277,12 @@ export default {
return null;
}
let hasBailedOut = false;
const partsOrQuestionsResponse = await this.getPartsOrQuestions();
if (partsOrQuestionsResponse.error) {
this.mainStore.setBailout(
bailoutMessage.NoPartsAvailable(partsOrQuestionsResponse.error.data));
this.mainStore.setBailout(bailoutMessage.NoPartsAvailable(partsOrQuestionsResponse.error.data));
window.console.error('Error on retrieving PartsOrQuestions');
this.$refs.siteFooter.removeLoader();
hasBailedOut = true;
this.hasBailedOut = true;
this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
this.$route
@ -289,7 +290,7 @@ export default {
}
// Comes from vehicleQuestionsMixin.navigateForward()
if (!hasBailedOut) {
if (!this.hasBailedOut) {
await this.navigateForward(
partsOrQuestionsResponse.data.partsOrQuestions,
this