Unit testcases
This commit is contained in:
parent
b9ef258183
commit
2a790bd5f2
5 changed files with 150 additions and 3 deletions
|
|
@ -306,6 +306,49 @@ describe("cart.vue", () => {
|
||||||
expect(found).toBe(true);
|
expect(found).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Service package discount Fee Cart Item
|
||||||
|
test("if there is service package discount fee on the order, a service package discount cart item should be added to the cart", () => {
|
||||||
|
// Arrange
|
||||||
|
const lineItems = {
|
||||||
|
glassParts: [],
|
||||||
|
supportingItems: [
|
||||||
|
{
|
||||||
|
description: null,
|
||||||
|
id: "bc00294e-6baa-403e-866e-52c267187a15",
|
||||||
|
kitPrice: 0,
|
||||||
|
laborAmount: 0,
|
||||||
|
partNumber: "DISC CASHSAVE70",
|
||||||
|
partType: "SERVICE PACKAGE DISCOUNT",
|
||||||
|
salesTax: null,
|
||||||
|
sellingPrice: -70,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
vaps: [],
|
||||||
|
promos: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const availableVaps = [];
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const { wrapper } = setupMocks({
|
||||||
|
props: {
|
||||||
|
modelValue: lineItems,
|
||||||
|
availableVaps: availableVaps,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.servicePackageDiscountCartItem).not.toBeNull();
|
||||||
|
expect(wrapper.vm.servicePackageDiscountCartItem.subTotal).toEqual(-70);
|
||||||
|
expect(wrapper.vm.servicePackageDiscountCartItem.salesTax).toEqual(0);
|
||||||
|
|
||||||
|
const found =
|
||||||
|
wrapper.vm.cartItems.findIndex(
|
||||||
|
(cartItem) => cartItem == wrapper.vm.servicePackageDiscountCartItem
|
||||||
|
) >= 0;
|
||||||
|
expect(found).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
// Other Supporting Items Cart Item
|
// Other Supporting Items Cart Item
|
||||||
test("if there are other supporting items on the order, an other supporting items cart item should be added to the cart but should not be displayed", () => {
|
test("if there are other supporting items on the order, an other supporting items cart item should be added to the cart but should not be displayed", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
|
||||||
|
|
@ -789,7 +789,9 @@ export default {
|
||||||
cartItem = {
|
cartItem = {
|
||||||
name:
|
name:
|
||||||
this.servicePackageDiscountCartItemName +
|
this.servicePackageDiscountCartItemName +
|
||||||
Math.abs(this.getTotalLineItemPrice(servicePackageDiscountLineItem)),
|
Math.abs(
|
||||||
|
baseMixin.methods.getTotalLineItemPrice(servicePackageDiscountLineItem)
|
||||||
|
),
|
||||||
category: cartItemCategories.SUPPORTING_ITEMS,
|
category: cartItemCategories.SUPPORTING_ITEMS,
|
||||||
cartItemType: cartItemTypes.SERVICE_PACKAGE_DISCOUNT,
|
cartItemType: cartItemTypes.SERVICE_PACKAGE_DISCOUNT,
|
||||||
isDisplayed: true,
|
isDisplayed: true,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ import quote from "@/layouts/quote/quote.vue";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-helper";
|
import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-helper";
|
||||||
import { nextTick } from "vue";
|
import { nextTick } from "vue";
|
||||||
|
import { experimentSettings } from "@/constants/experiments";
|
||||||
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import { support } from "jquery";
|
||||||
|
|
||||||
jest.mock("@/store", () => ({
|
jest.mock("@/store", () => ({
|
||||||
commit: jest.fn(),
|
commit: jest.fn(),
|
||||||
|
|
@ -60,9 +63,14 @@ const mockMixin = {
|
||||||
filterOutFees: jest.fn().mockImplementation(() => {
|
filterOutFees: jest.fn().mockImplementation(() => {
|
||||||
return null;
|
return null;
|
||||||
}),
|
}),
|
||||||
|
getSettingValue: jest.fn((settingName) => {
|
||||||
|
if (settingName === experimentSettings.SERVICE_PACKAGE_DISCOUNT) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let mockTierOnePrice = 501;
|
let mockTierOnePrice = 501;
|
||||||
|
|
||||||
const mockPriceOrderStoreAction = storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA;
|
const mockPriceOrderStoreAction = storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA;
|
||||||
|
|
@ -234,8 +242,12 @@ describe("quote.vue", () => {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
cardId: "123",
|
cardId: "123",
|
||||||
},
|
},
|
||||||
|
experimentSettings: {
|
||||||
|
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
//mock this to avoid needing to populate this.$route in an unrelated test
|
//mock this to avoid needing to populate this.$route in an unrelated test
|
||||||
wrapper.vm.getDefaultIsInsuranceSelectedValue = jest.fn();
|
wrapper.vm.getDefaultIsInsuranceSelectedValue = jest.fn();
|
||||||
|
|
||||||
|
|
@ -254,6 +266,47 @@ describe("quote.vue", () => {
|
||||||
// This should have its own test
|
// This should have its own test
|
||||||
//expect(vm.isInsuranceSelected !== null).toBe(true);
|
//expect(vm.isInsuranceSelected !== null).toBe(true);
|
||||||
});
|
});
|
||||||
|
test("Returns true if service package discount setting is true", async () => {
|
||||||
|
//Arrange
|
||||||
|
store.getters = {
|
||||||
|
lineItems: {
|
||||||
|
glassParts: ["item", "item2"],
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
lineItems: {
|
||||||
|
glassParts: ["item", "item2"],
|
||||||
|
},
|
||||||
|
payment: {},
|
||||||
|
serviceLocation: {
|
||||||
|
zipCode: "12345",
|
||||||
|
zipCodeCtu: "value",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
vehicle: {
|
||||||
|
cardId: "123",
|
||||||
|
},
|
||||||
|
experimentSettings: {
|
||||||
|
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
wrapper.vm.$route = { query: { isInsurance: "false" } };
|
||||||
|
|
||||||
|
const isServicePackageDiscount = mockMixin.methods.getSettingValue(
|
||||||
|
experimentSettings.SERVICE_PACKAGE_DISCOUNT
|
||||||
|
);
|
||||||
|
|
||||||
|
//Act
|
||||||
|
await quote.beforeRouteEnter.call(
|
||||||
|
wrapper.vm,
|
||||||
|
{ query: { fmgPage: "quote" } },
|
||||||
|
undefined,
|
||||||
|
(c) => c(wrapper.vm)
|
||||||
|
);
|
||||||
|
//Assert
|
||||||
|
expect(isServicePackageDiscount).toBe(true);
|
||||||
|
});
|
||||||
test("should default to insurance if query param 'isInsurance' is true", async () => {
|
test("should default to insurance if query param 'isInsurance' is true", async () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
store.getters = {
|
store.getters = {
|
||||||
|
|
@ -274,6 +327,9 @@ describe("quote.vue", () => {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
cardId: "123",
|
cardId: "123",
|
||||||
},
|
},
|
||||||
|
experimentSettings: {
|
||||||
|
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$route = { query: { isInsurance: "true" } };
|
wrapper.vm.$route = { query: { isInsurance: "true" } };
|
||||||
|
|
@ -309,6 +365,9 @@ describe("quote.vue", () => {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
cardId: "123",
|
cardId: "123",
|
||||||
},
|
},
|
||||||
|
experimentSettings: {
|
||||||
|
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$route = { query: { isInsurance: "false" } };
|
wrapper.vm.$route = { query: { isInsurance: "false" } };
|
||||||
|
|
@ -345,6 +404,9 @@ describe("quote.vue", () => {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
cardId: "123",
|
cardId: "123",
|
||||||
},
|
},
|
||||||
|
experimentSettings: {
|
||||||
|
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
// Ensure that query param isn't overriding selection
|
// Ensure that query param isn't overriding selection
|
||||||
|
|
@ -381,6 +443,9 @@ describe("quote.vue", () => {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
cardId: "123",
|
cardId: "123",
|
||||||
},
|
},
|
||||||
|
experimentSettings: {
|
||||||
|
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
// Ensure that query param isn't overriding selection
|
// Ensure that query param isn't overriding selection
|
||||||
|
|
@ -418,6 +483,9 @@ describe("quote.vue", () => {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
cardId: "123",
|
cardId: "123",
|
||||||
},
|
},
|
||||||
|
experimentSettings: {
|
||||||
|
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
mockTierOnePrice = 200;
|
mockTierOnePrice = 200;
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
@ -457,6 +525,9 @@ describe("quote.vue", () => {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
cardId: "123",
|
cardId: "123",
|
||||||
},
|
},
|
||||||
|
experimentSettings: {
|
||||||
|
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
mockTierOnePrice = 505;
|
mockTierOnePrice = 505;
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
@ -495,6 +566,9 @@ describe("quote.vue", () => {
|
||||||
vehicle: {
|
vehicle: {
|
||||||
cardId: "123",
|
cardId: "123",
|
||||||
},
|
},
|
||||||
|
experimentSettings: {
|
||||||
|
settingName: "SERVICE_PACKAGE_DISCOUNT",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$route = { query: null };
|
wrapper.vm.$route = { query: null };
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@ import {
|
||||||
mockProcessedCmsContent,
|
mockProcessedCmsContent,
|
||||||
inputQuestionWidgetAnswers,
|
inputQuestionWidgetAnswers,
|
||||||
} from "./service-package-question-test-helper";
|
} from "./service-package-question-test-helper";
|
||||||
|
import { containsLineItemWithPartType } from "@/helpers/service-package-helper";
|
||||||
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
import { partTypeStrings } from "@/constants/part-type-strings";
|
||||||
import { nextTick } from "vue";
|
import { nextTick } from "vue";
|
||||||
|
|
||||||
jest.mock("@/store", () => ({
|
jest.mock("@/store", () => ({
|
||||||
|
|
@ -68,6 +71,31 @@ 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);
|
||||||
|
});
|
||||||
it("should have the correct insurance pricing text when insurance is selected", () => {
|
it("should have the correct insurance pricing text when insurance is selected", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
mockProps.isInsuranceSelected = true;
|
mockProps.isInsuranceSelected = true;
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ export default {
|
||||||
return this.availableLineItems ?? [];
|
return this.availableLineItems ?? [];
|
||||||
},
|
},
|
||||||
supportingLineItems() {
|
supportingLineItems() {
|
||||||
return this.lineItems.supportingItems;
|
return this.lineItems?.supportingItems;
|
||||||
},
|
},
|
||||||
servicePackageAnswers() {
|
servicePackageAnswers() {
|
||||||
const cmsWidgetName = this.isInsuranceSelected
|
const cmsWidgetName = this.isInsuranceSelected
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue