78 lines
2.4 KiB
JavaScript
78 lines
2.4 KiB
JavaScript
import { getPricedMobileFeePart } from "./service-location-helper";
|
|
import { storeActions } from "@/constants/store-actions";
|
|
|
|
const mockStoreActionGetMobileFeePart = storeActions.GET_MOBILE_FEE_PART;
|
|
const mockStoreActionPriceOrderItemsAndSaveServerData =
|
|
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA;
|
|
|
|
jest.mock("@/mixins/base-mixin.js", () => ({
|
|
methods: {
|
|
getZipCodeData: jest.fn().mockImplementation(() => {
|
|
return Promise.resolve({
|
|
containsMilitaryBase: false,
|
|
isServiceable: true,
|
|
isValid: true,
|
|
state: "OH",
|
|
zipCodeCtu: "01820",
|
|
});
|
|
}),
|
|
|
|
dispatchStoreAction: jest.fn().mockImplementation((actionName) => {
|
|
if (actionName === mockStoreActionGetMobileFeePart) {
|
|
return Promise.resolve({
|
|
data: {
|
|
partNumber: "MOBILE FEE",
|
|
description: "MOBILE FEE",
|
|
partType: "FEE",
|
|
},
|
|
});
|
|
}
|
|
|
|
if (actionName === mockStoreActionPriceOrderItemsAndSaveServerData) {
|
|
return Promise.resolve([
|
|
{
|
|
partNumber: "MOBILE FEE",
|
|
description: "MOBILE FEE",
|
|
partType: "FEE",
|
|
laborAmount: 49.99,
|
|
sellingPrice: 0,
|
|
kitPrice: 0,
|
|
},
|
|
]);
|
|
}
|
|
}),
|
|
},
|
|
}));
|
|
|
|
describe("service-location-helper.js", () => {
|
|
it("Should return null if no service zip code is passed in", async () => {
|
|
// Arrange
|
|
const serviceZipCode = null;
|
|
const expected = null;
|
|
|
|
// Act
|
|
const result = await getPricedMobileFeePart(serviceZipCode);
|
|
|
|
// Assert
|
|
expect(result).toEqual(expected);
|
|
});
|
|
|
|
it("Should return the priced mobile fee part", async () => {
|
|
// Arrange
|
|
const serviceZipCode = "43235";
|
|
const expected = {
|
|
partNumber: "MOBILE FEE",
|
|
description: "MOBILE FEE",
|
|
partType: "FEE",
|
|
laborAmount: 49.99,
|
|
sellingPrice: 0,
|
|
kitPrice: 0,
|
|
};
|
|
|
|
// Act
|
|
const result = await getPricedMobileFeePart(serviceZipCode);
|
|
|
|
// Assert
|
|
expect(result).toEqual(expected);
|
|
});
|
|
});
|