This commit is contained in:
Kulbhushan Kaushik 2022-12-05 14:51:22 -05:00
parent 3efb2f6e15
commit b770d9c078
2 changed files with 12 additions and 6 deletions

View file

@ -61,7 +61,7 @@ const basePartResponse = {
};
describe("vehicle-parts.vue", () => {
test("Set cms content called on load", async (done) => {
test("Set cms content called on load", async () => {
//Arrange
useMainStore().pageData = jest.fn();
useMainStore().pageData.mockReturnValue(basePartResponse);
@ -95,7 +95,6 @@ describe("vehicle-parts.vue", () => {
//Assert
apiPromise.finally(() => {
expect(wrapper.vm.setCmsContent).toHaveBeenCalled();
done();
});
});
@ -104,6 +103,7 @@ describe("vehicle-parts.vue", () => {
useMainStore().pageData = jest.fn();
useMainStore().pageData.mockReturnValue(basePartResponse);
useMainStore().lineItems = { glassParts: null };
useMainStore().damage.isRepair = false;
const { wrapper } = setupMocks({
mountOptionsMockData: {
@ -202,7 +202,7 @@ describe("vehicle-parts.vue", () => {
//Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_PART_QUESTIONS,
navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route
);
});
@ -234,7 +234,7 @@ describe("vehicle-parts.vue", () => {
//Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
navigationScenarios.CLICKED_BACK_WITH_VIN_AND_NO_MORE_QUESTIONS,
navigationScenarios.CLICKED_BACK_WITH_NO_VIN_NOR_QUESTIONS,
wrapper.vm.$route
);
});
@ -371,6 +371,7 @@ describe("vehicle-parts.vue", () => {
(c) => c(wrapper.vm)
);
await wrapper.vm.forwardButtonAction();
//Assert
@ -401,10 +402,15 @@ function setupMocks({ pageHeaderWidgetHeaderText = {}, mountOptionsMockData = {}
},
};
const store = useMainStore();
let actionResult = [];
store.getCapabilityQuestions.mockImplementation(() => Promise.resolve({data: actionResult,}));
const apiPromise = Promise.resolve(apiResponses);
settleAllPromises.mockImplementation(() => apiPromise);
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
const mountOptions = getMountOptions(mountOptionsMockData);
const wrapper = shallowMount(vehicleParts, mountOptions);

View file

@ -405,7 +405,7 @@ export default {
// mimic part-questions page data for consistency
for (let partOrQuestion of partsOrQuestions) {
if (this.hasCapabilityQuestions([partOrQuestion])) {
let capabilityQuestionsForGlassLocation = (await this.mainStore.getCapabilityQuestions(this.mainStore.vehicle.carId, partOrQuestion.parts[0].partNumber)).data;
let capabilityQuestionsForGlassLocation = (await useMainStore().getCapabilityQuestions(useMainStore().vehicle.carId, partOrQuestion.parts[0].partNumber)).data;
capabilityQuestionsForGlassLocation.forEach((question) => {
question.answers = question.answers.map((answer) => {
@ -432,7 +432,7 @@ export default {
const collectedGlassParts = this.reducedGlassPartsArray(partsOrQuestions);
// save to store lineItems.glassParts
self.mainStore.updateGlassParts(collectedGlassParts);
useMainStore().updateGlassParts(collectedGlassParts);
self.$router.navigate(self.navigationScenarios.CLICKED_FORWARD_WITH_NO_MORE_QUESTIONS,self.$route);
}