unit test WIP
This commit is contained in:
parent
ffb7ca761d
commit
647c47c86a
1 changed files with 42 additions and 0 deletions
|
|
@ -121,6 +121,17 @@ const vehicleWithNoAdditionalPartsOrQuestionsMockResponse = {
|
|||
}
|
||||
};
|
||||
|
||||
const partsOrQuestionsErrorMockResponse = {
|
||||
data: {
|
||||
partsOrQuestions: [
|
||||
{
|
||||
parts: null
|
||||
}
|
||||
],
|
||||
partQuestions: null
|
||||
}
|
||||
};
|
||||
|
||||
jest.mock('bootstrap', () => ({
|
||||
getInstance: jest.fn(),
|
||||
getOrCreateInstance: jest.fn()
|
||||
|
|
@ -517,6 +528,37 @@ describe('vin-lookup.vue', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
test(
|
||||
'Error in getPartsOrQuestions call => bailout true and navigate forward with CLICKED_FORWARD_WITH_BAILOUT scenario',
|
||||
async () => {
|
||||
const user = userEvent.setup();
|
||||
mountOptions.global.stubs.vinQuestion = false;
|
||||
getPartsOrQuestions.mockResponse = partsOrQuestionsErrorMockResponse;
|
||||
|
||||
jest.spyOn(VinLookupComponent.methods, lookupVehicleByVin.methodName)
|
||||
.mockResolvedValue(lookupVehicleByVin.mockResponse);
|
||||
jest.spyOn(vehicleQuestionsMixin.methods, getPartsOrQuestions.methodName)
|
||||
.mockResolvedValue(getPartsOrQuestions.mockResponse);
|
||||
|
||||
const { container } = render(VinLookupComponent, mountOptions);
|
||||
|
||||
const vinInput = container.querySelector(vinInputSelector);
|
||||
await user.type(vinInput, mockValidVin);
|
||||
|
||||
const continueButton = container.querySelector(continueButtonQuerySelector);
|
||||
await user.click(continueButton);
|
||||
|
||||
await flushPromises();
|
||||
await waitFor(() => {
|
||||
expect(mockRouter.navigate).toHaveBeenCalledTimes(1);
|
||||
expect(mockRouter.navigate)
|
||||
.toHaveBeenCalledWith(
|
||||
navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT,
|
||||
mockRoute
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue