CSR-504 | Fix unit tests and formatting
This commit is contained in:
parent
200918f60f
commit
181de2d386
4 changed files with 38 additions and 22 deletions
|
|
@ -21,8 +21,8 @@ const storeActions = {
|
|||
GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions",
|
||||
GET_PARTS: "getParts",
|
||||
GET_WIPERS: "getWipers",
|
||||
GET_RAIN_DEFENSE: 'getRainDefense',
|
||||
GET_SUPPORTING_ITEMS: 'getSupportingItems',
|
||||
GET_RAIN_DEFENSE: "getRainDefense",
|
||||
GET_SUPPORTING_ITEMS: "getSupportingItems",
|
||||
GET_CAPABILITY_QUESTIONS: "getCapabilityQuestions",
|
||||
GET_PART_FROM_CAPABILITY_QUESTION_ANSWER: "getPartFromCapabilityQuestionAnswer",
|
||||
GET_MOLDING_QUESTIONS: "getMoldingQuestions",
|
||||
|
|
|
|||
|
|
@ -69,8 +69,12 @@ export default {
|
|||
// Call APIs
|
||||
const cmsContent = await fetchCmsContentForPage(to.query.fmgPage);
|
||||
const wipersPromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_WIPERS);
|
||||
const rainDefensePromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_RAIN_DEFENSE);
|
||||
const supportingItemsPromise = baseMixin.methods.dispatchStoreAction(storeActions.GET_SUPPORTING_ITEMS);
|
||||
const rainDefensePromise = baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.GET_RAIN_DEFENSE
|
||||
);
|
||||
const supportingItemsPromise = baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.GET_SUPPORTING_ITEMS
|
||||
);
|
||||
|
||||
const promiseResultMap = [
|
||||
{
|
||||
|
|
@ -89,9 +93,18 @@ export default {
|
|||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
const glassParts = [...store.getters.order.lineItems.glassParts];
|
||||
const availableLineItems = [resultMap.rainDefense, ...resultMap.supportingItems, ...resultMap.wipers, ...glassParts];
|
||||
const availableLineItems = [
|
||||
resultMap.rainDefense,
|
||||
...resultMap.supportingItems,
|
||||
...resultMap.wipers,
|
||||
...glassParts,
|
||||
];
|
||||
|
||||
const pricingResults = await baseMixin.methods.dispatchStoreAction(storeActions.PRICE_ORDER_ITEMS, availableLineItems, false);
|
||||
const pricingResults = await baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.PRICE_ORDER_ITEMS,
|
||||
availableLineItems,
|
||||
false
|
||||
);
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
|
|
|
|||
|
|
@ -874,13 +874,15 @@ export const actions = {
|
|||
getWipers(context) {
|
||||
const carId = context.getters.vehicle.carId;
|
||||
const serviceZipCode = context.getters.order.serviceLocation.zipCode;
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetWipers.method,
|
||||
endpoint: `${endpoints.GetWipers.url}/${carId}/${serviceZipCode}`,
|
||||
}).catch(error => {
|
||||
// The wiper service sometimes returns 500s on legitimate carId/zipCode combination - return empty array instead of breaking flow
|
||||
return [];
|
||||
});
|
||||
return globalMethods
|
||||
.callHttpClient({
|
||||
method: endpoints.GetWipers.method,
|
||||
endpoint: `${endpoints.GetWipers.url}/${carId}/${serviceZipCode}`,
|
||||
})
|
||||
.catch((error) => {
|
||||
// The wiper service sometimes returns 500s on legitimate carId/zipCode combination - return empty array instead of breaking flow
|
||||
return [];
|
||||
});
|
||||
},
|
||||
|
||||
getRainDefense(context) {
|
||||
|
|
@ -898,7 +900,7 @@ export const actions = {
|
|||
const carId = context.getters.vehicle.carId;
|
||||
const isRepair = context.getters.damage.isRepair;
|
||||
const numberOfChips = context.getters.damage.numberOfChips;
|
||||
const accountNumber = "82791";//context.getters.order.accountNumber.toString();
|
||||
const accountNumber = "82791"; //context.getters.order.accountNumber.toString();
|
||||
return globalMethods.callHttpClient({
|
||||
method: endpoints.GetSupportingItems.method,
|
||||
endpoint: endpoints.GetSupportingItems.url,
|
||||
|
|
@ -907,8 +909,8 @@ export const actions = {
|
|||
serviceType: isRepair ? "Repair" : "Replace",
|
||||
//accountNumber: accountNumber,
|
||||
parts: glassPartsArray,
|
||||
numberOfRepairChips: isRepair ? numberOfChips : 0
|
||||
},
|
||||
numberOfRepairChips: isRepair ? numberOfChips : 0,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
|
|
@ -1355,9 +1357,9 @@ export const actions = {
|
|||
// Price order actions
|
||||
// PLACEHOLDER, WILL CHANGE WHEN PRICING END POINT IS IMPLEMENTED
|
||||
priceOrderItems(context, availableLineItems) {
|
||||
availableLineItems.forEach((lineItem => {
|
||||
availableLineItems.forEach((lineItem) => {
|
||||
lineItem["price"] = parseFloat((Math.random() * 100).toFixed(2));
|
||||
}));
|
||||
});
|
||||
return availableLineItems;
|
||||
},
|
||||
// Misc order actions
|
||||
|
|
|
|||
|
|
@ -662,7 +662,7 @@ describe("Actions", () => {
|
|||
const context = state;
|
||||
|
||||
globalMethods.callHttpClient.mockImplementation(() => {
|
||||
return Promise.resolve({ data: { referralNumber: 123 } });
|
||||
return Promise.resolve({ data: { referralNumber: 123, order: {} } });
|
||||
});
|
||||
|
||||
const commit = jest.fn();
|
||||
|
|
@ -675,9 +675,10 @@ describe("Actions", () => {
|
|||
});
|
||||
|
||||
// Assert
|
||||
expect(response.data).toEqual({ referralNumber: 123 });
|
||||
expect(response.data).toEqual({ referralNumber: 123, order: {} });
|
||||
expect(commit).toBeCalledWith(storeMutations.UPDATE_STATE_WITH_ORDER_INFORMATION, {
|
||||
referralNumber: 123,
|
||||
order: {},
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -686,7 +687,7 @@ describe("Actions", () => {
|
|||
const context = state;
|
||||
|
||||
globalMethods.callHttpClient.mockImplementation(() => {
|
||||
return Promise.resolve({ data: { eon: "123" } });
|
||||
return Promise.resolve({ data: { eon: "123", order: {} } });
|
||||
});
|
||||
|
||||
context.commit = jest.fn();
|
||||
|
|
@ -709,7 +710,7 @@ describe("Actions", () => {
|
|||
const context = state;
|
||||
|
||||
globalMethods.callHttpClient.mockImplementation(() => {
|
||||
return Promise.resolve({ data: { eon: "123" } });
|
||||
return Promise.resolve({ data: { eon: "123", order: {} } });
|
||||
});
|
||||
|
||||
context.commit = jest.fn();
|
||||
|
|
|
|||
Loading…
Reference in a new issue