Fixing test

This commit is contained in:
Sneha 2024-05-20 17:58:29 +05:30
parent d606aa85f6
commit 024ac0adec

View file

@ -51,6 +51,12 @@ describe("service-package-question.vue", () => {
partType: "RAIN DEFENSE",
price: 35.5,
},
{
partNumber: "DISC CASHSAVE70",
description: null,
partType: "SERVICE PACKAGE DISCOUNT",
price: -70,
},
],
lineItems: {
supportingItems: [
@ -74,6 +80,15 @@ describe("service-package-question.vue", () => {
salesTax: null,
sellingPrice: 0,
},
{
description: null,
kitPrice: 0,
laborAmount: 0,
partNumber: "DISC CASHSAVE70",
partType: "SERVICE PACKAGE DISCOUNT",
salesTax: null,
sellingPrice: -70,
},
],
},
activePromos: [],
@ -98,69 +113,18 @@ 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
mockProps.lineItems.supportingItems
);
const servicePackageDiscountLineItem = findLineItemsWithPartType(
partType,
mockProps.lineItems.supportingItems
);
const servicePackageDiscountLineItem = findLineItemsWithPartType(partType, supportingItems);
wrapper.vm.getServicePackageDiscountPrice();
const price = baseMixin.methods.getTotalLineItemPrice(servicePackageDiscountLineItem[0]);
@ -169,27 +133,23 @@ describe("service-package-question.vue", () => {
it("isServicePackageDiscountOnOrder returns true if it contains service package discount lineItems", () => {
// Arrange
const wrapper = setupMocks({});
const recalLineItem = {
partNumber: "RECAL STATIC",
Description: "Recalibration",
partType: "recalibration",
Quantity: "1",
price: 150.0,
};
const servicePackageDiscountLineItem = {
partNumber: "DISC CASHSAVE70",
Description: null,
partType: "SERVICE PACKAGE DISCOUNT",
price: -70,
};
const lineItems = [recalLineItem, servicePackageDiscountLineItem];
const partType = partTypeStrings.SERVICE_PACKAGE_DISCOUNT;
// Act
const result = containsLineItemWithPartType(partType, lineItems);
// Assert
expect(result).toBe(true);
expect(wrapper.vm.isServicePackageDiscountOnOrder).toBe(true);
});
it("servicePackageDiscountParts should returns service package discount lineItems", () => {
// Arrange
const wrapper = setupMocks({});
// Assert
expect(wrapper.vm.servicePackageDiscountParts).toEqual([
{
partNumber: "DISC CASHSAVE70",
description: null,
partType: "SERVICE PACKAGE DISCOUNT",
price: -70,
},
]);
});
it("should have the correct insurance pricing text when insurance is selected", () => {
// Arrange