unit test
This commit is contained in:
parent
2a790bd5f2
commit
04b505c860
2 changed files with 125 additions and 1 deletions
|
|
@ -607,6 +607,35 @@ describe("quote.vue", () => {
|
|||
|
||||
expect(wrapper.vm.lineItems.promos !== null).toBe(true);
|
||||
});
|
||||
test("On forward button action save supporting lineItems", async () => {
|
||||
//Arrange
|
||||
store.getters.payment = {
|
||||
insuranceCoverage: {},
|
||||
isInsurance: false,
|
||||
};
|
||||
store.getters.order = {
|
||||
lineItems: [],
|
||||
payment: {
|
||||
parentAccountNumber: 167132,
|
||||
},
|
||||
};
|
||||
const { wrapper } = setupMocks({
|
||||
customMountOptions: {
|
||||
router: {
|
||||
navigateWithSaving: jest.fn(),
|
||||
},
|
||||
route: { quote },
|
||||
},
|
||||
});
|
||||
|
||||
wrapper.vm.forwardButtonAction();
|
||||
|
||||
expect(wrapper.vm.dispatchStoreAction).toHaveBeenCalledWith(
|
||||
"saveSupportingItems",
|
||||
wrapper.vm.lineItems.supportingItems,
|
||||
false
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function setupMocks({ customMountOptions }) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ import {
|
|||
mockProcessedCmsContent,
|
||||
inputQuestionWidgetAnswers,
|
||||
} from "./service-package-question-test-helper";
|
||||
import { containsLineItemWithPartType } from "@/helpers/service-package-helper";
|
||||
import {
|
||||
containsLineItemWithPartType,
|
||||
findLineItemsWithPartType,
|
||||
} from "@/helpers/service-package-helper";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||
import { nextTick } from "vue";
|
||||
|
|
@ -49,6 +52,30 @@ describe("service-package-question.vue", () => {
|
|||
price: 35.5,
|
||||
},
|
||||
],
|
||||
lineItems: {
|
||||
supportingItems: [
|
||||
{
|
||||
description: null,
|
||||
id: "b0c68683-da85-46ba-bc86-2642bd9d5fdb",
|
||||
kitPrice: 0,
|
||||
laborAmount: 0,
|
||||
partNumber: "RECYCLE FEE",
|
||||
partType: "REPLACE FEE",
|
||||
salesTax: null,
|
||||
sellingPrice: 0,
|
||||
},
|
||||
{
|
||||
description: null,
|
||||
id: "5f205a07-3c08-4244-9935-76d63a7bcd19",
|
||||
kitPrice: 0,
|
||||
laborAmount: 395,
|
||||
partNumber: "RECAL STATIC",
|
||||
partType: "RECALIBRATION",
|
||||
salesTax: null,
|
||||
sellingPrice: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
activePromos: [],
|
||||
};
|
||||
const packageNameKey = "05_01_CSR_Quote_Standard_Repair";
|
||||
|
|
@ -71,6 +98,74 @@ describe("service-package-question.vue", () => {
|
|||
},
|
||||
]);
|
||||
});
|
||||
it("should emit relevant service package discount items in an array", async () => {
|
||||
// Arrange
|
||||
const wrapper = setupMocks({});
|
||||
// Act
|
||||
wrapper.componentVM.selectedPackageName = "TierTwo";
|
||||
await nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.emitted()["servicePackageDiscountSelected"][0][0]).toEqual(
|
||||
mockProps.lineItems.supportingItems
|
||||
);
|
||||
});
|
||||
it("should return undefined when there is no discount", () => {
|
||||
const wrapper = setupMocks({});
|
||||
const partType = partTypeStrings.SERVICE_PACKAGE_DISCOUNT;
|
||||
wrapper.vm.isServicePackageDiscountOnOrder = containsLineItemWithPartType(
|
||||
partType,
|
||||
mockProps.lineItems.supportingItems
|
||||
);
|
||||
|
||||
const price = wrapper.vm.getServicePackageDiscountPrice();
|
||||
|
||||
expect(price).toBeUndefined();
|
||||
});
|
||||
it("should return price when there is discount", () => {
|
||||
const wrapper = setupMocks({});
|
||||
const partType = partTypeStrings.SERVICE_PACKAGE_DISCOUNT;
|
||||
const supportingItems = [
|
||||
{
|
||||
description: null,
|
||||
id: "b0c68683-da85-46ba-bc86-2642bd9d5fdb",
|
||||
kitPrice: 0,
|
||||
laborAmount: 0,
|
||||
partNumber: "RECYCLE FEE",
|
||||
partType: "REPLACE FEE",
|
||||
salesTax: null,
|
||||
sellingPrice: 0,
|
||||
},
|
||||
{
|
||||
description: null,
|
||||
id: "5f205a07-3c08-4244-9935-76d63a7bcd19",
|
||||
kitPrice: 0,
|
||||
laborAmount: 395,
|
||||
partNumber: "RECAL STATIC",
|
||||
partType: "RECALIBRATION",
|
||||
salesTax: null,
|
||||
sellingPrice: 0,
|
||||
},
|
||||
{
|
||||
description: null,
|
||||
kitPrice: 0,
|
||||
laborAmount: 0,
|
||||
partNumber: "DISC CASHSAVE70",
|
||||
partType: "SERVICE PACKAGE DISCOUNT",
|
||||
salesTax: null,
|
||||
sellingPrice: -70,
|
||||
},
|
||||
];
|
||||
wrapper.vm.isServicePackageDiscountOnOrder = containsLineItemWithPartType(
|
||||
partType,
|
||||
supportingItems
|
||||
);
|
||||
const servicePackageDiscountLineItem = findLineItemsWithPartType(partType, supportingItems);
|
||||
wrapper.vm.getServicePackageDiscountPrice();
|
||||
const price = baseMixin.methods.getTotalLineItemPrice(servicePackageDiscountLineItem[0]);
|
||||
|
||||
expect(Math.abs(price)).toEqual(70);
|
||||
});
|
||||
it("isServicePackageDiscountOnOrder returns true if it contains service package discount lineItems", () => {
|
||||
// Arrange
|
||||
const wrapper = setupMocks({});
|
||||
|
|
|
|||
Loading…
Reference in a new issue