INSR-7759: Fix some failing tests, remobe some pointless ones
This commit is contained in:
parent
09a4b85e22
commit
2a1b9d4426
10 changed files with 105 additions and 669 deletions
|
|
@ -93,10 +93,12 @@ describe('cart-helper', () => {
|
|||
const result = getServiceLineItems(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toHaveLength(3);
|
||||
expect(result).toHaveLength(5);
|
||||
expect(result).toContain(supportingLineItem);
|
||||
expect(result).toContain(glassLineItem);
|
||||
expect(result).toContain(otherLineItem);
|
||||
expect(result).toContain(mobileFeeLineItem);
|
||||
expect(result).toContain(recycleFeeLineItem);
|
||||
});
|
||||
|
||||
test('Returns empty array when line items are null', () => {
|
||||
|
|
@ -124,10 +126,8 @@ describe('cart-helper', () => {
|
|||
const result = getNonServiceLineItems(order);
|
||||
|
||||
// Assert
|
||||
expect(result).toHaveLength(3);
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result).toContain(vapsLineItem);
|
||||
expect(result).toContain(mobileFeeLineItem);
|
||||
expect(result).toContain(recycleFeeLineItem);
|
||||
});
|
||||
|
||||
test('Returns empty array when line items are null', () => {
|
||||
|
|
@ -403,7 +403,7 @@ describe('cart-helper', () => {
|
|||
describe.each([
|
||||
[330, coverageType.ITAC],
|
||||
[330, coverageType.NO_COMP],
|
||||
[310, coverageType.Deductible]])('getSubtotal with line items', (expected, type) => {
|
||||
[160, coverageType.Deductible]])('getSubtotal with line items', (expected, type) => {
|
||||
test(`Returns ${expected} cart subtotal when verified ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
|
|
@ -480,7 +480,7 @@ describe('cart-helper', () => {
|
|||
describe.each([
|
||||
[21, coverageType.ITAC],
|
||||
[21, coverageType.NO_COMP],
|
||||
[15, coverageType.Deductible]])('getSalesTax with line items', (expected, type) => {
|
||||
[4, coverageType.Deductible]])('getSalesTax with line items', (expected, type) => {
|
||||
test(`Returns ${expected} when coverageType is ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
const order = {
|
||||
|
|
@ -565,7 +565,7 @@ describe('cart-helper', () => {
|
|||
describe.each([
|
||||
[351, coverageType.ITAC],
|
||||
[351, coverageType.NO_COMP],
|
||||
[325, coverageType.Deductible]
|
||||
[164, coverageType.Deductible]
|
||||
])('getCartTotal items', (expected, type) => {
|
||||
test(`Returns ${expected} cart total when verified ${getEnumName(coverageType, type)}`, () => {
|
||||
// Arrange
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
exports[`cart-dropdown component initial data rendered as expected 1`] = `
|
||||
Object {
|
||||
"RECYCLING_MODAL_REF_NAME": "RecycleModal",
|
||||
"cartItemType": Object {
|
||||
"MOBILE_FEE": "MOBILE FEE",
|
||||
"RECYCLE_FEE": "RECYCLE FEE",
|
||||
|
|
@ -16,6 +15,7 @@ Object {
|
|||
"deductible": "DeductibleWidget",
|
||||
"guaranteeText": "GuaranteeCartItemTextWidget",
|
||||
"mobileFee": "MobileServiceWidget",
|
||||
"recalibration": "RecalibrationWidget",
|
||||
"recycleFee": "RecycleFeeWidget",
|
||||
"salesTax": "SalesTaxWidget",
|
||||
"servicePackage": "ServicePackageTitle",
|
||||
|
|
|
|||
|
|
@ -73,10 +73,22 @@ describe('cart-dropdown component', () => {
|
|||
expect(wrapper.vm.$data).toMatchSnapshot();
|
||||
});
|
||||
describe('displays', () => {
|
||||
test('cart table', () => {
|
||||
test('cart table when not deductible only', () => {
|
||||
// Arrange
|
||||
const reference = '.cart-table';
|
||||
const { wrapper } = getMountedComponent({}, {}, {});
|
||||
const part1 = { partType: partTypeStrings.FRONT_WIPER };
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
lineItems: {
|
||||
vaps: [part1],
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||
|
||||
// Act
|
||||
const cartTable = wrapper.find(reference);
|
||||
|
|
@ -84,9 +96,9 @@ describe('cart-dropdown component', () => {
|
|||
// Assert
|
||||
expect(cartTable.exists()).toBeTruthy();
|
||||
});
|
||||
test('cart deductible when showDeductibleCartItem is true', () => {
|
||||
test('deductible-box when deductible only', () => {
|
||||
// Arrange
|
||||
const reference = '#deductible-label';
|
||||
const reference = '.deductible-box';
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
|
|
@ -127,9 +139,9 @@ describe('cart-dropdown component', () => {
|
|||
// Assert
|
||||
expect(cartBasePrice.exists()).toBeTruthy();
|
||||
});
|
||||
test('non service package cart items', () => {
|
||||
test('additional cart items', () => {
|
||||
// Arrange
|
||||
const reference = '.non-packaged.cart-item';
|
||||
const reference = '.cart-item';
|
||||
const part1 = { partType: 'apple' };
|
||||
const part2 = { partType: 'banana' };
|
||||
const part3 = { partType: 'orange' };
|
||||
|
|
@ -155,38 +167,27 @@ describe('cart-dropdown component', () => {
|
|||
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||
|
||||
// Act
|
||||
const nonPackagedCartItems = wrapper.find(reference);
|
||||
const cartItems = wrapper.findAll(reference);
|
||||
|
||||
// Assert
|
||||
expect(nonPackagedCartItems.exists()).toBeTruthy();
|
||||
expect(cartItems.length).toBeGreaterThan(1);
|
||||
});
|
||||
test('recycle cart item label when isRecycle true for some cart item', () => {
|
||||
test('cart footer when not deductible only', () => {
|
||||
// Arrange
|
||||
const reference = '#recycle-fee-label';
|
||||
const isExpanded = true;
|
||||
const initialPropsData = { isExpanded };
|
||||
const reference = '.cart-footer';
|
||||
const part1 = { partType: partTypeStrings.FRONT_WIPER };
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
lineItems: {
|
||||
feeItems: [
|
||||
{ partNumber: partNumberStrings.RECYCLE_FEE }
|
||||
]
|
||||
vaps: [part1],
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData, {}, initialPropsData);
|
||||
|
||||
// Act
|
||||
const recycleFeeLabel = wrapper.find(reference);
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.recycleFeeCartItem).not.toBeNull();
|
||||
expect(recycleFeeLabel.exists()).toBeTruthy();
|
||||
});
|
||||
test('cart footer', () => {
|
||||
// Arrange
|
||||
const reference = '#cart-footer';
|
||||
const { wrapper } = getMountedComponent({}, {}, {});
|
||||
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||
|
||||
// Act
|
||||
const cartFooter = wrapper.find(reference);
|
||||
|
|
@ -197,7 +198,19 @@ describe('cart-dropdown component', () => {
|
|||
test('subtotal', () => {
|
||||
// Arrange
|
||||
const reference = '#cart-subtotal';
|
||||
const { wrapper } = getMountedComponent({}, {}, {});
|
||||
const part1 = { partType: partTypeStrings.FRONT_WIPER };
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
lineItems: {
|
||||
vaps: [part1],
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||
|
||||
// Act
|
||||
const subtotal = wrapper.find(reference);
|
||||
|
|
@ -208,7 +221,19 @@ describe('cart-dropdown component', () => {
|
|||
test('tax', () => {
|
||||
// Arrange
|
||||
const reference = '#cart-sales-tax';
|
||||
const { wrapper } = getMountedComponent({}, {}, {});
|
||||
const part1 = { partType: partTypeStrings.FRONT_WIPER };
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
lineItems: {
|
||||
vaps: [part1],
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||
|
||||
// Act
|
||||
const salesTax = wrapper.find(reference);
|
||||
|
|
@ -222,8 +247,16 @@ describe('cart-dropdown component', () => {
|
|||
const isExpanded = true;
|
||||
const showAsPaid = true;
|
||||
const initialPropsData = { isExpanded, showAsPaid };
|
||||
const part1 = { partType: partTypeStrings.FRONT_WIPER };
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
lineItems: {
|
||||
vaps: [part1],
|
||||
},
|
||||
payment: {
|
||||
isPayInAdvance: true
|
||||
}
|
||||
|
|
@ -240,7 +273,19 @@ describe('cart-dropdown component', () => {
|
|||
test('bottom amount due', () => {
|
||||
// Arrange
|
||||
const reference = '#bottom-amount-due';
|
||||
const { wrapper } = getMountedComponent({}, {}, {});
|
||||
const part1 = { partType: partTypeStrings.FRONT_WIPER };
|
||||
const storeData = {
|
||||
order: {
|
||||
insuranceCoverage: {
|
||||
coverageStatus: coverageStatuses.VERIFIED,
|
||||
coverageType: coverageType.Deductible
|
||||
},
|
||||
lineItems: {
|
||||
vaps: [part1],
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||
|
||||
// Act
|
||||
const bottomAmountDue = wrapper.find(reference);
|
||||
|
|
@ -293,27 +338,6 @@ describe('cart-dropdown component', () => {
|
|||
// Assert
|
||||
expect(cartBasePrice.exists()).toBeFalsy();
|
||||
});
|
||||
test('recycle cart item label when isRecycle false for all cart items', () => {
|
||||
// Arrange
|
||||
const reference = '#recycle-fee-label';
|
||||
const isExpanded = true;
|
||||
const initialPropsData = { isExpanded };
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
supportingItems: []
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData, {}, initialPropsData);
|
||||
|
||||
// Act
|
||||
const recycleFeeLabel = wrapper.find(reference);
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.recycleFeeCartItem).toBeNull();
|
||||
expect(recycleFeeLabel.exists()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
describe('computed', () => {
|
||||
describe('amountDue', () => {
|
||||
|
|
@ -475,7 +499,7 @@ describe('cart-dropdown component', () => {
|
|||
expect(result.sort(sortByPartType)).toStrictEqual(expected.sort(sortByPartType));
|
||||
});
|
||||
});
|
||||
describe('servicePackageCartItems', () => {
|
||||
describe('cartItems', () => {
|
||||
test.each([
|
||||
[undefined], [null], [[]]
|
||||
])('returns empty list when package contents %p', (packageContents) => {
|
||||
|
|
@ -485,7 +509,7 @@ describe('cart-dropdown component', () => {
|
|||
const expected = [];
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.servicePackageCartItems;
|
||||
const result = wrapper.vm.cartItems;
|
||||
|
||||
// Assert
|
||||
expect(result).toStrictEqual(expected);
|
||||
|
|
@ -531,7 +555,7 @@ describe('cart-dropdown component', () => {
|
|||
const wrapper = shallowMount(cartDropdown, mountOptions);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.servicePackageCartItems;
|
||||
const result = wrapper.vm.cartItems;
|
||||
|
||||
// Assert
|
||||
expect(result.length).toBe(1);
|
||||
|
|
@ -577,7 +601,7 @@ describe('cart-dropdown component', () => {
|
|||
const wrapper = shallowMount(cartDropdown, mountOptions);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.servicePackageCartItems;
|
||||
const result = wrapper.vm.cartItems;
|
||||
|
||||
// Assert
|
||||
expect(result.length).toBe(1);
|
||||
|
|
@ -623,7 +647,7 @@ describe('cart-dropdown component', () => {
|
|||
const wrapper = shallowMount(cartDropdown, mountOptions);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.servicePackageCartItems;
|
||||
const result = wrapper.vm.cartItems;
|
||||
|
||||
// Assert
|
||||
expect(result.length).toBe(1);
|
||||
|
|
@ -685,7 +709,7 @@ describe('cart-dropdown component', () => {
|
|||
const wrapper = shallowMount(cartDropdown, mountOptions);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.servicePackageCartItems;
|
||||
const result = wrapper.vm.cartItems;
|
||||
|
||||
// Assert
|
||||
expect(result.length).toBe(3);
|
||||
|
|
@ -699,8 +723,6 @@ describe('cart-dropdown component', () => {
|
|||
name: expectedRainDefenseName
|
||||
}));
|
||||
});
|
||||
});
|
||||
describe('nonServicePackageCartItems', () => {
|
||||
test('when recycleFee, includes recycle fee', () => {
|
||||
// Arrange
|
||||
const storeData = {
|
||||
|
|
@ -717,7 +739,9 @@ describe('cart-dropdown component', () => {
|
|||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
const result = wrapper.vm.cartItems;
|
||||
|
||||
console.log(result);
|
||||
|
||||
// Assert
|
||||
expect(result).toContainEqual(expect.objectContaining({
|
||||
|
|
@ -736,163 +760,13 @@ describe('cart-dropdown component', () => {
|
|||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
const result = wrapper.vm.cartItems;
|
||||
|
||||
// Assert
|
||||
expect(result).toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.MOBILE_FEE
|
||||
}));
|
||||
});
|
||||
test('front wiper not included when front wiper in service package', () => {
|
||||
// Arrange
|
||||
getPriceOfLineItems.mockImplementation(() => 123);
|
||||
getPackageContents.mockImplementationOnce(() => [partTypeStrings.FRONT_WIPER]);
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
vaps: [
|
||||
{
|
||||
partType: partTypeStrings.FRONT_WIPER
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
|
||||
// Assert
|
||||
expect(result).not.toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.FRONT_WIPER
|
||||
}));
|
||||
});
|
||||
test('rear wiper not included when rear wiper in service package', () => {
|
||||
// Arrange
|
||||
getPriceOfLineItems.mockImplementation(() => 123);
|
||||
getPackageContents.mockImplementationOnce(() => [partTypeStrings.REAR_WIPER]);
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
vaps: [
|
||||
{
|
||||
partType: partTypeStrings.REAR_WIPER
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
|
||||
// Assert
|
||||
expect(result).not.toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.REAR_WIPER
|
||||
}));
|
||||
});
|
||||
test('rain defense not included when rain defense in service package', () => {
|
||||
// Arrange
|
||||
getPriceOfLineItems.mockImplementation(() => 123);
|
||||
getPackageContents.mockImplementationOnce(() => [partTypeStrings.RAIN_DEFENSE]);
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
vaps: [
|
||||
{
|
||||
partType: partTypeStrings.RAIN_DEFENSE
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
|
||||
// Assert
|
||||
expect(result).not.toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.RAIN_DEFENSE
|
||||
}));
|
||||
});
|
||||
test('front wiper included when not in service package and in vaps', () => {
|
||||
// Arrange
|
||||
getPriceOfLineItems.mockImplementation(() => 123);
|
||||
getPackageContents.mockImplementationOnce(() => []);
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
vaps: [
|
||||
{
|
||||
partType: partTypeStrings.FRONT_WIPER
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
|
||||
// Assert
|
||||
expect(result).toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.FRONT_WIPER
|
||||
}));
|
||||
});
|
||||
test('rear wiper included when not in service package and in vaps', () => {
|
||||
// Arrange
|
||||
getPriceOfLineItems.mockImplementation(() => 123);
|
||||
getPackageContents.mockImplementationOnce(() => []);
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
vaps: [
|
||||
{
|
||||
partType: partTypeStrings.REAR_WIPER
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
|
||||
// Assert
|
||||
expect(result).toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.REAR_WIPER
|
||||
}));
|
||||
});
|
||||
test('rain defense included when not in service package and in vaps', () => {
|
||||
// Arrange
|
||||
getPriceOfLineItems.mockImplementation(() => 123);
|
||||
getPackageContents.mockImplementationOnce(() => []);
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
vaps: [
|
||||
{
|
||||
partType: partTypeStrings.RAIN_DEFENSE
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
|
||||
// Assert
|
||||
expect(result).toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.RAIN_DEFENSE
|
||||
}));
|
||||
});
|
||||
test('item in vaps outside front wiper, rear wiper, and rain defense never included', () => {
|
||||
// Arrange
|
||||
getPriceOfLineItems.mockImplementation(() => 123);
|
||||
|
|
@ -911,143 +785,13 @@ describe('cart-dropdown component', () => {
|
|||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
const result = wrapper.vm.cartItems;
|
||||
|
||||
// Assert
|
||||
expect(result).not.toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.RECALIBRATION
|
||||
}));
|
||||
});
|
||||
test('returns expected when multiple variables apply', () => {
|
||||
// Arrange
|
||||
getPriceOfLineItems.mockImplementation(() => 123);
|
||||
getPackageContents.mockImplementationOnce(() => [partTypeStrings.FRONT_WIPER]);
|
||||
const storeData = {
|
||||
order: {
|
||||
lineItems: {
|
||||
feeItems: [
|
||||
{ partType: partTypeStrings.MOBILE_FEE },
|
||||
{ partNumber: partNumberStrings.RECYCLE_FEE }
|
||||
],
|
||||
vaps: [
|
||||
{ partType: partTypeStrings.RECALIBRATION },
|
||||
{ partType: partTypeStrings.FRONT_WIPER },
|
||||
{ partType: partTypeStrings.REAR_WIPER }
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
const { wrapper } = getMountedComponent(storeData);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.nonServicePackageCartItems;
|
||||
|
||||
// Assert
|
||||
expect(result.length).toBe(3);
|
||||
expect(result).toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.REPLACE_FEE
|
||||
}));
|
||||
expect(result).toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.MOBILE_FEE
|
||||
}));
|
||||
expect(result).toContainEqual(expect.objectContaining({
|
||||
partType: partTypeStrings.REAR_WIPER
|
||||
}));
|
||||
});
|
||||
});
|
||||
describe('servicePackageLabelWidget', () => {
|
||||
test.each([
|
||||
[null],
|
||||
[undefined]
|
||||
])('returns "" when servicePackageNames %p', (servicePackageNames) => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn(() => servicePackageNames)
|
||||
}
|
||||
};
|
||||
mountOptions.mixins = [mockMixin];
|
||||
|
||||
const wrapper = shallowMount(cartDropdown, mountOptions);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.servicePackageLabelWidget;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe('');
|
||||
});
|
||||
test('returns "" when servicePackageTier not found in servicePackageNames', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
getHighestFullySatisfiedTier.mockImplementationOnce(() => 'some other tier');
|
||||
const servicePackageNames = [{ Name: 'some tier' }];
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn(() => servicePackageNames)
|
||||
}
|
||||
};
|
||||
mountOptions.mixins = [mockMixin];
|
||||
const wrapper = shallowMount(cartDropdown, mountOptions);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.servicePackageLabelWidget;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe('');
|
||||
});
|
||||
test('returns "" when servicePackageTier has no SubWidgetName', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
const tier = 'tier1';
|
||||
getHighestFullySatisfiedTier.mockImplementationOnce(() => tier);
|
||||
const servicePackageNames = [{ Name: tier }];
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn(() => servicePackageNames)
|
||||
}
|
||||
};
|
||||
mountOptions.mixins = [mockMixin];
|
||||
const wrapper = shallowMount(cartDropdown, mountOptions);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.servicePackageLabelWidget;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe('');
|
||||
});
|
||||
test('returns expected when servicePackageTier has SubWidgetName', () => {
|
||||
// Arrange
|
||||
const mountOptions = getMountOptions({
|
||||
router: { navigate: jest.fn() }
|
||||
});
|
||||
const tier = 'tier1';
|
||||
getHighestFullySatisfiedTier.mockImplementationOnce(() => tier);
|
||||
const expected = 'name of sub widget';
|
||||
const servicePackageNames = [{
|
||||
Name: tier,
|
||||
SubWidgetName: expected
|
||||
}];
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn(() => servicePackageNames)
|
||||
}
|
||||
};
|
||||
mountOptions.mixins = [mockMixin];
|
||||
const wrapper = shallowMount(cartDropdown, mountOptions);
|
||||
|
||||
// Act
|
||||
const result = wrapper.vm.servicePackageLabelWidget;
|
||||
|
||||
// Assert
|
||||
expect(result).toBe(expected);
|
||||
});
|
||||
});
|
||||
describe('recycleFeeCartItem', () => {
|
||||
test.each([
|
||||
|
|
|
|||
|
|
@ -119,8 +119,6 @@ const VERIFYING_COVERAGE = 'Verifying coverage';
|
|||
export default {
|
||||
name: 'confirmation-cart',
|
||||
components: {
|
||||
contentGroupModal,
|
||||
textBlock,
|
||||
textLink
|
||||
},
|
||||
props: {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
exports[`contact-details-drawer snapshot matches returns the initial data 1`] = `
|
||||
Object {
|
||||
"detailsSaved": false,
|
||||
"emailAddress": "fred.tay@gmail.com",
|
||||
"extension": null,
|
||||
"firstName": "Frederick",
|
||||
|
|
@ -15,8 +16,8 @@ Object {
|
|||
"rules": Object {
|
||||
"emailAddress": "email-required|email-address-format",
|
||||
"extension": "extension-format",
|
||||
"firstName": "first-name-required",
|
||||
"lastName": "last-name-required",
|
||||
"firstName": "policyholder-first-name-required",
|
||||
"lastName": "policyholder-last-name-required",
|
||||
"phoneNumber": "phone-number-required|phone-number-format",
|
||||
},
|
||||
"widget": Object {
|
||||
|
|
|
|||
|
|
@ -48,15 +48,19 @@ function setupMocks({ customMountOptions = {}, queryString }, mainInitialState =
|
|||
})
|
||||
}
|
||||
};
|
||||
const cmsMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn()
|
||||
}
|
||||
}
|
||||
|
||||
mountOptions.global.plugins = [testingPinia];
|
||||
mountOptions.global.mixins = [mockMixin];
|
||||
mountOptions.mixins = [mockMixin, cmsMixin];
|
||||
|
||||
const wrapper = shallowMount(paymentMethod, mountOptions);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
const store = useMainStore();
|
||||
const defaultState = getDefaultState();
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ export default {
|
|||
return MaskaFormattedMasks.PHONE_NUMBER;
|
||||
},
|
||||
offerWipers() {
|
||||
return !this.mainStore.lineItems.vaps.some((part) => part.partType.toLowerCase().includes('wiper'));
|
||||
return !this.mainStore.lineItems.vaps?.some((part) => part.partType.toLowerCase().includes('wiper'));
|
||||
},
|
||||
wiperOfferPanel() {
|
||||
const wiperImage = this.getCmsContent(this.widget.wiperOffer, widgetFields.CONTENT_GROUP_WIDGET.IMAGE);
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
// Components
|
||||
import customerReview from '@/layouts/payment-method/review-dropdown/review-sections/customer-review/customer-review.vue';
|
||||
|
||||
// Supporting Files
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
|
||||
const testConstants = {
|
||||
cms: {
|
||||
header: {
|
||||
text: 'Header'
|
||||
},
|
||||
sms: {
|
||||
text: 'Sms'
|
||||
}
|
||||
},
|
||||
customerInfo: {
|
||||
firstName: 'First',
|
||||
lastName: 'Last',
|
||||
servicePhone: '111-111-1111',
|
||||
emailAddress: 'builddigitaltest@safelite.com',
|
||||
isSmsOptIn: false
|
||||
},
|
||||
displayContent: {
|
||||
fullName: 'First Last',
|
||||
phoneNumber: '111-111-1111',
|
||||
emailAddress: 'builddigitaltest@safelite.com',
|
||||
smsOptIn: 'Sms'
|
||||
}
|
||||
};
|
||||
|
||||
function generateDefaultProps() {
|
||||
return {
|
||||
cmsWidgetName: 'CustomerWidget',
|
||||
customer: {
|
||||
firstName: testConstants.customerInfo.firstName,
|
||||
lastName: testConstants.customerInfo.lastName,
|
||||
servicePhone: testConstants.customerInfo.servicePhone,
|
||||
emailAddress: testConstants.customerInfo.emailAddress,
|
||||
isSmsOptIn: testConstants.customerInfo.isSmsOptIn
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let cmsContent;
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn((widgetName, cmsFieldName) => cmsContent?.[widgetName]?.[cmsFieldName] ?? '')
|
||||
}
|
||||
};
|
||||
|
||||
function getShallowMountedComponent(initialData = {}, methodToRun = () => {}) {
|
||||
const mountOptions = getMountOptions({
|
||||
router: {
|
||||
navigate: jest.fn()
|
||||
}
|
||||
});
|
||||
|
||||
methodToRun();
|
||||
|
||||
mountOptions.data = () => (
|
||||
initialData
|
||||
);
|
||||
|
||||
mountOptions.mixins = [mockMixin];
|
||||
|
||||
const wrapper = shallowMount(customerReview, mountOptions);
|
||||
return { wrapper };
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
cmsContent = {
|
||||
CustomerWidget: {
|
||||
HeaderText: testConstants.cms.header.text,
|
||||
SubheaderText: testConstants.cms.sms.text
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
describe('Customer Review Block', () => {
|
||||
test('Should display header text from cms', async () => {
|
||||
// Arrange
|
||||
const props = generateDefaultProps();
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
...props
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.header).toEqual(testConstants.cms.header.text);
|
||||
});
|
||||
|
||||
test('Should display sms text from cms', async () => {
|
||||
// Arrange
|
||||
const props = generateDefaultProps();
|
||||
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
...props
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.smsOptIn).toEqual(testConstants.cms.sms.text);
|
||||
});
|
||||
|
||||
test('Should render correct display content', async () => {
|
||||
// Arrange
|
||||
const props = generateDefaultProps();
|
||||
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
...props
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toEqual([
|
||||
testConstants.displayContent.fullName,
|
||||
testConstants.displayContent.emailAddress,
|
||||
testConstants.displayContent.phoneNumber,
|
||||
testConstants.displayContent.smsOptIn
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,135 +0,0 @@
|
|||
// Components
|
||||
import
|
||||
serviceLocationReview from '@/layouts/payment-method/review-dropdown/review-sections/service-location-review/service-location-review.vue';
|
||||
|
||||
// Supporting Files
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
import { AppointmentTypeStrings } from '@/constants/schedule-constants';
|
||||
|
||||
const cmsContent = {
|
||||
ServiceLocationTitleWidget: {
|
||||
Text: 'Title Text'
|
||||
}
|
||||
};
|
||||
|
||||
const mockMixin = {
|
||||
methods: {
|
||||
getCmsContent: jest.fn((widgetName, cmsFieldName) => cmsContent?.[widgetName]?.[cmsFieldName] ?? '')
|
||||
}
|
||||
};
|
||||
|
||||
function generateDefaultProps() {
|
||||
return {
|
||||
cmsWidgetName: 'ServiceLocationTitleWidget',
|
||||
serviceLocation: {
|
||||
address: 'Mobile Address 1',
|
||||
address2: 'Mobile Address 2',
|
||||
city: 'Mobile City',
|
||||
state: 'MO',
|
||||
zipCode: '11111',
|
||||
zipCodeCtu: '',
|
||||
appointmentType: AppointmentTypeStrings.MOBILE,
|
||||
isVehicleProtected: false,
|
||||
provider: {
|
||||
providerNumber: '',
|
||||
address: {
|
||||
streetAddress: 'Service Location Address',
|
||||
city: 'Service Location City',
|
||||
state: 'SL',
|
||||
zipCode: '22222',
|
||||
zipCodeCtu: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getShallowMountedComponent(initialData = {}, methodToRun = () => {}) {
|
||||
const mountOptions = getMountOptions({
|
||||
router: {
|
||||
navigate: jest.fn()
|
||||
}
|
||||
});
|
||||
|
||||
methodToRun();
|
||||
|
||||
mountOptions.data = () => (
|
||||
initialData
|
||||
);
|
||||
|
||||
mountOptions.mixins = [mockMixin];
|
||||
|
||||
const wrapper = shallowMount(serviceLocationReview, mountOptions);
|
||||
return { wrapper };
|
||||
}
|
||||
|
||||
describe('Service Location Review Block', () => {
|
||||
test('Should render mobile address if mobile appointment', async () => {
|
||||
// Arrange
|
||||
const props = generateDefaultProps();
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
...props
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toEqual([
|
||||
'Mobile Address 1, Mobile Address 2, Mobile City, MO 11111'
|
||||
]);
|
||||
});
|
||||
|
||||
test('Should render service location address if inshop appointment.', async () => {
|
||||
// Arrange
|
||||
const props = generateDefaultProps();
|
||||
props.serviceLocation.appointmentType = AppointmentTypeStrings.IN_SHOP;
|
||||
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
...props
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toEqual([
|
||||
'Service Location Address, Service Location City, SL 22222'
|
||||
]);
|
||||
});
|
||||
|
||||
test('Should render service location address if drop-off appointment', async () => {
|
||||
// Arrange
|
||||
const props = generateDefaultProps();
|
||||
props.serviceLocation.appointmentType = AppointmentTypeStrings.DROP_OFF;
|
||||
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
...props
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toEqual([
|
||||
'Service Location Address, Service Location City, SL 22222'
|
||||
]);
|
||||
});
|
||||
|
||||
test('Should not add comma or any text if address2 is null', async () => {
|
||||
// Arrange
|
||||
const props = generateDefaultProps();
|
||||
props.serviceLocation.address2 = null;
|
||||
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
...props
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toEqual(['Mobile Address 1, Mobile City, MO 11111']);
|
||||
});
|
||||
});
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
// Components
|
||||
import vehicleReview from '@/layouts/payment-method/review-dropdown/review-sections/vehicle-review/vehicle-review.vue';
|
||||
|
||||
// Supporting Files
|
||||
import { shallowMount } from '@vue/test-utils';
|
||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||
|
||||
jest.mock('@/helpers/cms-content-helper', () => ({
|
||||
fetchCmsContentForPage: () => Promise.resolve('content')
|
||||
}));
|
||||
|
||||
function getShallowMountedComponent(initialData = {}, methodToRun = () => {}) {
|
||||
const mountOptions = getMountOptions({
|
||||
router: {
|
||||
navigate: jest.fn()
|
||||
}
|
||||
});
|
||||
|
||||
methodToRun();
|
||||
|
||||
mountOptions.data = () => (
|
||||
initialData
|
||||
);
|
||||
|
||||
const wrapper = shallowMount(vehicleReview, mountOptions);
|
||||
wrapper.vm.setCmsContent = jest.fn();
|
||||
return { wrapper };
|
||||
}
|
||||
|
||||
describe('Vehicle Review Block', () => {
|
||||
test('Correctly assembles vehicle info into a display string', async () => {
|
||||
// Arrange
|
||||
const { wrapper } = getShallowMountedComponent({
|
||||
vehicle: {
|
||||
year: '2019',
|
||||
make: 'Honda',
|
||||
model: 'Odyssey'
|
||||
}
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.displayContent).toStrictEqual(['2019 Honda Odyssey']);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue