INSR-7757: Fix some tests
This commit is contained in:
parent
8bf7d282d4
commit
32bf06ea59
8 changed files with 91 additions and 308 deletions
|
|
@ -7,19 +7,21 @@ Object {
|
||||||
"MOBILE_FEE": "MOBILE FEE",
|
"MOBILE_FEE": "MOBILE FEE",
|
||||||
"RECYCLE_FEE": "RECYCLE FEE",
|
"RECYCLE_FEE": "RECYCLE FEE",
|
||||||
"VAP": "VAP",
|
"VAP": "VAP",
|
||||||
|
"WARRANTY": "WARRANTY",
|
||||||
},
|
},
|
||||||
"isExpanded": false,
|
|
||||||
"widget": Object {
|
"widget": Object {
|
||||||
"amountDue": "AmountDueTextWidget",
|
"amountDue": "AmountDueTextWidget",
|
||||||
"amountPaid": "AmountPaidTextWidget",
|
"amountPaid": "AmountPaidTextWidget",
|
||||||
"basePrice": "BasePriceWidget",
|
"basePrice": "BasePriceWidget",
|
||||||
"deductible": "DeductibleWidget",
|
"deductible": "DeductibleWidget",
|
||||||
|
"guaranteeText": "GuaranteeCartItemTextWidget",
|
||||||
"mobileFee": "MobileServiceWidget",
|
"mobileFee": "MobileServiceWidget",
|
||||||
"recycleFee": "RecycleFeeWidget",
|
"recycleFee": "RecycleFeeWidget",
|
||||||
"salesTax": "SalesTaxWidget",
|
"salesTax": "SalesTaxWidget",
|
||||||
"servicePackage": "ServicePackageTitle",
|
"servicePackage": "ServicePackageTitle",
|
||||||
"subtotal": "SubtotalWidget",
|
"subtotal": "SubtotalWidget",
|
||||||
"vapsItemDescriptions": "VapsItemDescriptions",
|
"vapsItemDescriptions": "VapsItemDescriptions",
|
||||||
|
"warrantyText": "WarrantyCartItemTextWidget",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
||||||
|
|
@ -73,47 +73,10 @@ describe('cart-dropdown component', () => {
|
||||||
expect(wrapper.vm.$data).toMatchSnapshot();
|
expect(wrapper.vm.$data).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
describe('displays', () => {
|
describe('displays', () => {
|
||||||
test('cart dropdown head', () => {
|
|
||||||
// Arrange
|
|
||||||
const reference = '#cart-dropdown-head';
|
|
||||||
const { wrapper } = getMountedComponent(cartDropdown);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const head = wrapper.find(reference);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(head.exists()).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('cart dropdown head is visible', () => {
|
|
||||||
// Arrange
|
|
||||||
const reference = '#cart-dropdown-head';
|
|
||||||
const { wrapper } = getMountedComponent(cartDropdown, {}, { showDropdownHeader: true });
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const head = wrapper.find(reference);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(head.exists()).toBeTruthy();
|
|
||||||
expect(head.classes()).toContain('cart-toggle');
|
|
||||||
});
|
|
||||||
test('cart dropdown head is not visible', () => {
|
|
||||||
// Arrange
|
|
||||||
const reference = '#cart-dropdown-head';
|
|
||||||
const { wrapper } = getMountedComponent(cartDropdown, {}, { showDropdownHeader: false });
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const head = wrapper.find(reference);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(head.exists()).toBeTruthy();
|
|
||||||
expect(head.classes()).not.toContain('cart-toggle');
|
|
||||||
});
|
|
||||||
test('cart table', () => {
|
test('cart table', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#cart-table';
|
const reference = '.cart-table';
|
||||||
const isExpanded = true;
|
const { wrapper } = getMountedComponent({}, {}, {});
|
||||||
const initialData = { isExpanded };
|
|
||||||
const { wrapper } = getMountedComponent({}, {}, initialData);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const cartTable = wrapper.find(reference);
|
const cartTable = wrapper.find(reference);
|
||||||
|
|
@ -121,11 +84,9 @@ describe('cart-dropdown component', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(cartTable.exists()).toBeTruthy();
|
expect(cartTable.exists()).toBeTruthy();
|
||||||
});
|
});
|
||||||
test('cart deductible when showDeductibleLineItem is true', () => {
|
test('cart deductible when showDeductibleCartItem is true', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#cart-deductible';
|
const reference = '#deductible-label';
|
||||||
const isExpanded = true;
|
|
||||||
const initialData = { isExpanded };
|
|
||||||
const storeData = {
|
const storeData = {
|
||||||
order: {
|
order: {
|
||||||
insuranceCoverage: {
|
insuranceCoverage: {
|
||||||
|
|
@ -134,7 +95,7 @@ describe('cart-dropdown component', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(storeData, {}, initialData);
|
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const cartDeductible = wrapper.find(reference);
|
const cartDeductible = wrapper.find(reference);
|
||||||
|
|
@ -144,9 +105,7 @@ describe('cart-dropdown component', () => {
|
||||||
});
|
});
|
||||||
test('cart base price when showDeductibleLineItem is false', () => {
|
test('cart base price when showDeductibleLineItem is false', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#cart-base-price';
|
const reference = '#base-price-label';
|
||||||
const isExpanded = true;
|
|
||||||
const initialData = { isExpanded };
|
|
||||||
const storeData = {
|
const storeData = {
|
||||||
order: {
|
order: {
|
||||||
currentDeductible: 0,
|
currentDeductible: 0,
|
||||||
|
|
@ -160,7 +119,7 @@ describe('cart-dropdown component', () => {
|
||||||
isClaimRegistrationRequired: true
|
isClaimRegistrationRequired: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(storeData, {}, initialData);
|
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const cartBasePrice = wrapper.find(reference);
|
const cartBasePrice = wrapper.find(reference);
|
||||||
|
|
@ -168,25 +127,32 @@ describe('cart-dropdown component', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(cartBasePrice.exists()).toBeTruthy();
|
expect(cartBasePrice.exists()).toBeTruthy();
|
||||||
});
|
});
|
||||||
test('service package', () => {
|
|
||||||
// Arrange
|
|
||||||
const reference = '#cart-service-package';
|
|
||||||
const isExpanded = true;
|
|
||||||
const initialData = { isExpanded };
|
|
||||||
const { wrapper } = getMountedComponent({}, {}, initialData);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const servicePackage = wrapper.find(reference);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(servicePackage.exists()).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('non service package cart items', () => {
|
test('non service package cart items', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#non-packaged-cart-items';
|
const reference = '.non-packaged.cart-item';
|
||||||
const isExpanded = true;
|
const part1 = { partType: 'apple' };
|
||||||
const initialData = { isExpanded };
|
const part2 = { partType: 'banana' };
|
||||||
const { wrapper } = getMountedComponent({}, {}, initialData);
|
const part3 = { partType: 'orange' };
|
||||||
|
const mobileFee = { partType: 'mobile' };
|
||||||
|
const storeData = {
|
||||||
|
order: {
|
||||||
|
currentDeductible: 0,
|
||||||
|
lineItems: {
|
||||||
|
glassParts: [part1],
|
||||||
|
supportingItems: [part2, part3],
|
||||||
|
otherParts: [],
|
||||||
|
feeItems: [mobileFee]
|
||||||
|
},
|
||||||
|
insuranceCoverage: {
|
||||||
|
coverageStatus: coverageStatuses.VERIFIED,
|
||||||
|
coverageType: coverageType.ITAC
|
||||||
|
}
|
||||||
|
},
|
||||||
|
issConfig: {
|
||||||
|
isClaimRegistrationRequired: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const nonPackagedCartItems = wrapper.find(reference);
|
const nonPackagedCartItems = wrapper.find(reference);
|
||||||
|
|
@ -220,9 +186,7 @@ describe('cart-dropdown component', () => {
|
||||||
test('cart footer', () => {
|
test('cart footer', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#cart-footer';
|
const reference = '#cart-footer';
|
||||||
const isExpanded = true;
|
const { wrapper } = getMountedComponent({}, {}, {});
|
||||||
const initialData = { isExpanded };
|
|
||||||
const { wrapper } = getMountedComponent({}, {}, initialData);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const cartFooter = wrapper.find(reference);
|
const cartFooter = wrapper.find(reference);
|
||||||
|
|
@ -233,9 +197,7 @@ describe('cart-dropdown component', () => {
|
||||||
test('subtotal', () => {
|
test('subtotal', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#cart-subtotal';
|
const reference = '#cart-subtotal';
|
||||||
const isExpanded = true;
|
const { wrapper } = getMountedComponent({}, {}, {});
|
||||||
const initialData = { isExpanded };
|
|
||||||
const { wrapper } = getMountedComponent({}, {}, initialData);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const subtotal = wrapper.find(reference);
|
const subtotal = wrapper.find(reference);
|
||||||
|
|
@ -246,9 +208,7 @@ describe('cart-dropdown component', () => {
|
||||||
test('tax', () => {
|
test('tax', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#cart-sales-tax';
|
const reference = '#cart-sales-tax';
|
||||||
const isExpanded = true;
|
const { wrapper } = getMountedComponent({}, {}, {});
|
||||||
const initialData = { isExpanded };
|
|
||||||
const { wrapper } = getMountedComponent({}, {}, initialData);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const salesTax = wrapper.find(reference);
|
const salesTax = wrapper.find(reference);
|
||||||
|
|
@ -280,9 +240,7 @@ describe('cart-dropdown component', () => {
|
||||||
test('bottom amount due', () => {
|
test('bottom amount due', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#bottom-amount-due';
|
const reference = '#bottom-amount-due';
|
||||||
const isExpanded = true;
|
const { wrapper } = getMountedComponent({}, {}, {});
|
||||||
const initialData = { isExpanded };
|
|
||||||
const { wrapper } = getMountedComponent({}, {}, initialData);
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const bottomAmountDue = wrapper.find(reference);
|
const bottomAmountDue = wrapper.find(reference);
|
||||||
|
|
@ -295,8 +253,6 @@ describe('cart-dropdown component', () => {
|
||||||
test('cart deductible when showDeductibleLineItem is false', () => {
|
test('cart deductible when showDeductibleLineItem is false', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#cart-deductible';
|
const reference = '#cart-deductible';
|
||||||
const isExpanded = true;
|
|
||||||
const initialData = { isExpanded };
|
|
||||||
const storeData = {
|
const storeData = {
|
||||||
order: {
|
order: {
|
||||||
currentDeductible: 0,
|
currentDeductible: 0,
|
||||||
|
|
@ -310,7 +266,7 @@ describe('cart-dropdown component', () => {
|
||||||
isClaimRegistrationRequired: true
|
isClaimRegistrationRequired: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(storeData, {}, initialData);
|
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const cartDeductible = wrapper.find(reference);
|
const cartDeductible = wrapper.find(reference);
|
||||||
|
|
@ -321,8 +277,6 @@ describe('cart-dropdown component', () => {
|
||||||
test('cart base price when showDeductibleLineItem is true', () => {
|
test('cart base price when showDeductibleLineItem is true', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const reference = '#cart-base-price';
|
const reference = '#cart-base-price';
|
||||||
const isExpanded = true;
|
|
||||||
const initialData = { isExpanded };
|
|
||||||
const storeData = {
|
const storeData = {
|
||||||
order: {
|
order: {
|
||||||
insuranceCoverage: {
|
insuranceCoverage: {
|
||||||
|
|
@ -331,7 +285,7 @@ describe('cart-dropdown component', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent(storeData, {}, initialData);
|
const { wrapper } = getMountedComponent(storeData, {}, {});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const cartBasePrice = wrapper.find(reference);
|
const cartBasePrice = wrapper.find(reference);
|
||||||
|
|
@ -1223,91 +1177,6 @@ describe('cart-dropdown component', () => {
|
||||||
expect(result.name).toBe(expectedName);
|
expect(result.name).toBe(expectedName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('packagePrice', () => {
|
|
||||||
test('returns 0 when servicePackageCartItems is empty', () => {
|
|
||||||
// Arrange
|
|
||||||
getPriceOfLineItems.mockImplementation(() => 123);
|
|
||||||
getPackageContents.mockImplementationOnce(() => []);
|
|
||||||
const storeData = {
|
|
||||||
order: {
|
|
||||||
lineItems: {
|
|
||||||
vaps: [
|
|
||||||
{
|
|
||||||
partType: partTypeStrings.REAR_WIPER
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(storeData);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = wrapper.vm.packagePrice;
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(0);
|
|
||||||
});
|
|
||||||
test('returns expected when servicePackageCartItems not empty', () => {
|
|
||||||
// Arrange
|
|
||||||
const rearPrice = 101;
|
|
||||||
const frontPrice = 9;
|
|
||||||
getPriceOfLineItems.mockImplementation((lineItems) => {
|
|
||||||
if (lineItems.some((item) => item?.partType === partTypeStrings.FRONT_WIPER)) {
|
|
||||||
return frontPrice;
|
|
||||||
}
|
|
||||||
if (lineItems.some((item) => item?.partType === partTypeStrings.REAR_WIPER)) {
|
|
||||||
return rearPrice;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
getPackageContents.mockImplementationOnce(() => [partTypeStrings.FRONT_WIPER, partTypeStrings.REAR_WIPER]);
|
|
||||||
const storeData = {
|
|
||||||
order: {
|
|
||||||
lineItems: {
|
|
||||||
vaps: [
|
|
||||||
{ partType: partTypeStrings.FRONT_WIPER },
|
|
||||||
{ partType: partTypeStrings.REAR_WIPER }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(storeData);
|
|
||||||
const expectedPrice = 110;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = wrapper.vm.packagePrice;
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(expectedPrice);
|
|
||||||
});
|
|
||||||
test('returns expected when servicePackageCartItems has one item', () => {
|
|
||||||
// Arrange
|
|
||||||
const frontPrice = 9;
|
|
||||||
getPriceOfLineItems.mockImplementation((lineItems) => {
|
|
||||||
if (lineItems.some((item) => item?.partType === partTypeStrings.FRONT_WIPER)) {
|
|
||||||
return frontPrice;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
});
|
|
||||||
getPackageContents.mockImplementationOnce(() => [partTypeStrings.FRONT_WIPER, partTypeStrings.REAR_WIPER]);
|
|
||||||
const storeData = {
|
|
||||||
order: {
|
|
||||||
lineItems: {
|
|
||||||
vaps: [
|
|
||||||
{ partType: partTypeStrings.FRONT_WIPER }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(storeData);
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const result = wrapper.vm.packagePrice;
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(result).toBe(frontPrice);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
describe('method', () => {
|
describe('method', () => {
|
||||||
const dollarAmount = '$84.00';
|
const dollarAmount = '$84.00';
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<div
|
<div
|
||||||
v-for="(item, i) in nonServicePackageCartItems"
|
v-for="(item, i) in nonServicePackageCartItems"
|
||||||
:key="i"
|
:key="i"
|
||||||
class="cart-item">
|
class="cart-item non-packaged">
|
||||||
<div class="price-row">
|
<div class="price-row">
|
||||||
<span
|
<span
|
||||||
v-if="item.cartItemType === cartItemType.RECYCLE_FEE"
|
v-if="item.cartItemType === cartItemType.RECYCLE_FEE"
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
<div
|
<div
|
||||||
v-for="(item, i) in servicePackageCartItems"
|
v-for="(item, i) in servicePackageCartItems"
|
||||||
:key="i"
|
:key="i"
|
||||||
class="cart-item">
|
class="cart-item packaged">
|
||||||
<div class="price-row">
|
<div class="price-row">
|
||||||
<span>{{ item?.name ?? '' }}</span>
|
<span>{{ item?.name ?? '' }}</span>
|
||||||
<span>{{ formatAmountInDollars(item?.subTotal ?? 0) }}</span>
|
<span>{{ formatAmountInDollars(item?.subTotal ?? 0) }}</span>
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,10 @@
|
||||||
import calendarOptions from '@/constants/calendar-options';
|
import calendarOptions from '@/constants/calendar-options';
|
||||||
|
|
||||||
// Supporting Files
|
// Supporting Files
|
||||||
import { shallowMount, mount } from '@vue/test-utils';
|
import { shallowMount } from '@vue/test-utils';
|
||||||
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
import { getMountOptions } from '@/helpers/unit-test-helper.js';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
import addToCalendar from '@/layouts/order-confirmation/add-to-calendar/add-to-calendar.vue';
|
import addToCalendar from '@/layouts/order-confirmation/add-to-calendar/add-to-calendar.vue';
|
||||||
import { createTestingPinia } from '@pinia/testing';
|
|
||||||
|
|
||||||
const appointmentText = 'Appointment content';
|
const appointmentText = 'Appointment content';
|
||||||
function setupMocks({ customMountOptions }) {
|
function setupMocks({ customMountOptions }) {
|
||||||
|
|
@ -21,49 +20,6 @@ function setupMocks({ customMountOptions }) {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
const wrapper = shallowMount(addToCalendar, mountOptions);
|
const wrapper = shallowMount(addToCalendar, mountOptions);
|
||||||
wrapper.vm.$refs.calendarModalQuestion.openModal = jest.fn();
|
|
||||||
return { wrapper };
|
|
||||||
}
|
|
||||||
|
|
||||||
const calendarModalQuestionStub = {
|
|
||||||
render: () => {}
|
|
||||||
};
|
|
||||||
|
|
||||||
const mockMixin = {
|
|
||||||
methods: {
|
|
||||||
getCmsContent: jest.fn().mockImplementation(() => appointmentText)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRun = () => {}, mixin = mockMixin) {
|
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
router: {
|
|
||||||
navigate: jest.fn(),
|
|
||||||
navigateToExternalUrl: jest.fn()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mountOptions.global.stubs = {
|
|
||||||
calendarModalQuestion: calendarModalQuestionStub
|
|
||||||
};
|
|
||||||
|
|
||||||
const testingPinia = createTestingPinia({
|
|
||||||
initialState: {
|
|
||||||
main: mainInitialState
|
|
||||||
}
|
|
||||||
});
|
|
||||||
useMainStore(testingPinia);
|
|
||||||
methodToRun();
|
|
||||||
|
|
||||||
mountOptions.global.mixins[0].methods.getSettingValue = jest.fn(() => 'false');
|
|
||||||
mountOptions.global.plugins = [testingPinia];
|
|
||||||
mountOptions.mixins = [mixin];
|
|
||||||
mountOptions.data = () => (
|
|
||||||
initialData
|
|
||||||
);
|
|
||||||
|
|
||||||
const wrapper = shallowMount(addToCalendar, mountOptions);
|
|
||||||
wrapper.vm.$refs.calendarModalQuestion.openModal = jest.fn();
|
|
||||||
return { wrapper };
|
return { wrapper };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,51 +75,8 @@ afterEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
const sessionStorage = {
|
|
||||||
schedule: {
|
|
||||||
date: '2019-01-01',
|
|
||||||
startTime: '09:00',
|
|
||||||
endTime: '10:00',
|
|
||||||
routeCode: '000'
|
|
||||||
},
|
|
||||||
lineItems: {
|
|
||||||
glassParts: [
|
|
||||||
{
|
|
||||||
partNumber: 'ABC123'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
supportingItems: []
|
|
||||||
},
|
|
||||||
serviceLocation: {
|
|
||||||
address: '',
|
|
||||||
address2: null,
|
|
||||||
city: '',
|
|
||||||
state: 'AZ',
|
|
||||||
appointmentType: 'Inshop',
|
|
||||||
zipCode: '12345',
|
|
||||||
zipCodeCtu: '01234',
|
|
||||||
provider: {
|
|
||||||
providerNumber: '123',
|
|
||||||
address: {
|
|
||||||
streetAddress: 'test1',
|
|
||||||
city: 'test',
|
|
||||||
state: 'AZ',
|
|
||||||
zipCode: '12345',
|
|
||||||
zipCodeCtu: '01234'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
damage: {
|
|
||||||
isRepair: false
|
|
||||||
},
|
|
||||||
referralNumber: '1234567',
|
|
||||||
payment: {
|
|
||||||
isInsurance: true
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('Add-to-calendar methods...', () => {
|
describe('Add-to-calendar methods...', () => {
|
||||||
test('Add-to-calendar should trigger openModal method', () => {
|
test('Add-to-calendar should trigger open options', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
customMountOptions: {
|
customMountOptions: {
|
||||||
|
|
@ -183,10 +96,11 @@ describe('Add-to-calendar methods...', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.openCalendarModal();
|
wrapper.vm.openCalendarOptions();
|
||||||
|
await wrapper.vm.$nextTick();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$refs.calendarModalQuestion.openModal).toBeCalled();
|
expect(wrapper.vm.$refs.calendarOptions.open).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getCalendarData should return expected model value.', () => {
|
test('getCalendarData should return expected model value.', () => {
|
||||||
|
|
|
||||||
|
|
@ -209,12 +209,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openCalendarOptions() {
|
openCalendarOptions() {
|
||||||
console.log('Opening calendar options');
|
|
||||||
this.calendarOptionsOpen = true;
|
this.calendarOptionsOpen = true;
|
||||||
window.addEventListener('click', this.clickListener);
|
window.addEventListener('click', this.clickListener);
|
||||||
},
|
},
|
||||||
calendarOptionSelected(calendarOptionIndex) {
|
calendarOptionSelected(calendarOptionIndex) {
|
||||||
console.log('Selected calendar option:', calendarOptionIndex);
|
|
||||||
this.setCalendarAppointment(this.calendarValues[calendarOptionIndex]);
|
this.setCalendarAppointment(this.calendarValues[calendarOptionIndex]);
|
||||||
this.calendarOptionsOpen = false;
|
this.calendarOptionsOpen = false;
|
||||||
},
|
},
|
||||||
|
|
@ -255,7 +253,6 @@ export default {
|
||||||
download('SafeliteAppointment.ics', calBody);
|
download('SafeliteAppointment.ics', calBody);
|
||||||
},
|
},
|
||||||
closeCalendarOptions() {
|
closeCalendarOptions() {
|
||||||
console.log('Closing calendar options');
|
|
||||||
this.calendarOptionsOpen = false;
|
this.calendarOptionsOpen = false;
|
||||||
window.removeEventListener('click', this.clickListener);
|
window.removeEventListener('click', this.clickListener);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,35 +7,36 @@ describe('calendar-option-selection.vue', () => {
|
||||||
const url = 'iCal url';
|
const url = 'iCal url';
|
||||||
const name = 'iCal';
|
const name = 'iCal';
|
||||||
const icon = 'iCal.svg';
|
const icon = 'iCal.svg';
|
||||||
|
const url2 = 'Google url';
|
||||||
|
const name2 = 'Google';
|
||||||
|
const icon2 = 'Google.svg';
|
||||||
const expectedEmit = [
|
const expectedEmit = [
|
||||||
[
|
[
|
||||||
{
|
1
|
||||||
url,
|
|
||||||
name,
|
|
||||||
icon
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
const wrapper = shallowMount(calendarModalQuestion, {
|
const wrapper = shallowMount(calendarOptionSelection, {
|
||||||
propsData: {
|
propsData: {
|
||||||
calendarOptionsData: [
|
calendarOptionsData: [
|
||||||
{
|
{
|
||||||
url,
|
url,
|
||||||
name,
|
name,
|
||||||
icon
|
icon
|
||||||
|
},
|
||||||
|
{
|
||||||
|
url: url2,
|
||||||
|
name: name2,
|
||||||
|
icon: icon2
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.vm.$refs.calendarOptions.closeModal = jest.fn();
|
|
||||||
wrapper.vm.selectedCalendarOption = name;
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
wrapper.vm.setSelectedCalendarOption();
|
wrapper.vm.setSelectedCalendarOption(1);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.emitted()['update:modelValue']).toEqual(expectedEmit);
|
expect(wrapper.emitted()['calendar-option-selected']).toEqual(expectedEmit);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
expect(actualEmail).toBe(emailAddress);
|
expect(actualEmail).toBe(emailAddress);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('confirmationEmailText', () => {
|
describe('orderConfirmationUpdateAppointmentText', () => {
|
||||||
const greaterId = '>';
|
const greaterId = '>';
|
||||||
const lessId = '<';
|
const lessId = '<';
|
||||||
test.each([
|
test.each([
|
||||||
|
|
@ -383,7 +383,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent(initialStore, {}, mockStoreActions);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.confirmationEmailText;
|
const text = wrapper.vm.orderConfirmationUpdateAppointmentText;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(text).toBe(expected);
|
expect(text).toBe(expected);
|
||||||
|
|
@ -391,13 +391,13 @@ describe('OrderConfirmation.vue', () => {
|
||||||
});
|
});
|
||||||
describe('appointmentTimeText', () => {
|
describe('appointmentTimeText', () => {
|
||||||
test.each([
|
test.each([
|
||||||
['Between 9 AM - 10 AM', '09:00', '10:00'],
|
['Your appointment is at 9 AM - 10 AM', '09:00', '10:00'],
|
||||||
['Between 1 PM - 5 PM', '13:00', '17:00'],
|
['Your appointment is at 1 PM - 5 PM', '13:00', '17:00'],
|
||||||
['Between 8:30 AM - 3 PM', '08:30', '15:00'],
|
['Your appointment is at 8:30 AM - 3 PM', '08:30', '15:00'],
|
||||||
['Between 1 AM - 2 AM', '01:00', '02:00'],
|
['Your appointment is at 1 AM - 2 AM', '01:00', '02:00'],
|
||||||
['Between 12 AM - 2 AM', '00:00', '02:00'],
|
['Your appointment is at 12 AM - 2 AM', '00:00', '02:00'],
|
||||||
['Between 12 PM - 2 AM', '12:00', '02:00'],
|
['Your appointment is at 12 PM - 2 AM', '12:00', '02:00'],
|
||||||
['Between 11 PM - 12 AM', '23:00', '00:00']
|
['Your appointment is at 11 PM - 12 AM', '23:00', '00:00']
|
||||||
])('should return Mobile time in expected format "%p" when start time "%p" and end time "%p"', (expected, startTime, endTime) => {
|
])('should return Mobile time in expected format "%p" when start time "%p" and end time "%p"', (expected, startTime, endTime) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = deepClone(sessionStorage);
|
const order = deepClone(sessionStorage);
|
||||||
|
|
@ -438,12 +438,12 @@ describe('OrderConfirmation.vue', () => {
|
||||||
expect(testValue).toEqual('Drop off before 9:30 AM');
|
expect(testValue).toEqual('Drop off before 9:30 AM');
|
||||||
});
|
});
|
||||||
test.each([
|
test.each([
|
||||||
['at 9:00 AM', '09:00', '10:00'],
|
['Your appointment is at 9:00 AM', '09:00', '10:00'],
|
||||||
['at 1:00 PM', '13:00', '17:00'],
|
['Your appointment is at 1:00 PM', '13:00', '17:00'],
|
||||||
['at 8:30 AM', '08:30', '15:00'],
|
['Your appointment is at 8:30 AM', '08:30', '15:00'],
|
||||||
['at 1:00 AM', '01:00', '02:00'],
|
['Your appointment is at 1:00 AM', '01:00', '02:00'],
|
||||||
['at 12:00 AM', '00:00', '02:00'],
|
['Your appointment is at 12:00 AM', '00:00', '02:00'],
|
||||||
['at 12:00 PM', '12:00', '02:00']
|
['Your appointment is at 12:00 PM', '12:00', '02:00']
|
||||||
])('should return In Shop time in expected format "%p" when start time "%p"', (expected, startTime, endTime) => {
|
])('should return In Shop time in expected format "%p" when start time "%p"', (expected, startTime, endTime) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = deepClone(sessionStorage);
|
const order = deepClone(sessionStorage);
|
||||||
|
|
@ -479,8 +479,8 @@ describe('OrderConfirmation.vue', () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const expectedServiceLocation = '123 Service Rd., Box 4,<br/> Columbus, OH 12345';
|
const expectedServiceLocation = '123 Service Rd., Box 4, Columbus, OH 12345';
|
||||||
const expectedShopLocation = '304 Provider Ln.,<br/> Pittsburg, PA 16001';
|
const expectedShopLocation = '304 Provider Ln., Pittsburg, PA 16001';
|
||||||
test.each([
|
test.each([
|
||||||
AppointmentTypeStrings.MOBILE,
|
AppointmentTypeStrings.MOBILE,
|
||||||
AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP
|
AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP
|
||||||
|
|
@ -554,7 +554,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = '123 Service Rd., Box 4,<br/> Columbus, OH 12345';
|
const expected = '123 Service Rd., Box 4, Columbus, OH 12345';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.serviceLocationFullAddress;
|
const text = wrapper.vm.serviceLocationFullAddress;
|
||||||
|
|
@ -568,7 +568,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = ', Box 4,<br/> Columbus, OH 12345';
|
const expected = ', Box 4, Columbus, OH 12345';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.serviceLocationFullAddress;
|
const text = wrapper.vm.serviceLocationFullAddress;
|
||||||
|
|
@ -582,7 +582,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = '123 Service Rd., <br/> Columbus, OH 12345';
|
const expected = '123 Service Rd., Columbus, OH 12345';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.serviceLocationFullAddress;
|
const text = wrapper.vm.serviceLocationFullAddress;
|
||||||
|
|
@ -596,7 +596,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = '123 Service Rd., Box 4,<br/> , OH 12345';
|
const expected = '123 Service Rd., Box 4, , OH 12345';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.serviceLocationFullAddress;
|
const text = wrapper.vm.serviceLocationFullAddress;
|
||||||
|
|
@ -610,7 +610,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = '123 Service Rd., Box 4,<br/> Columbus, 12345';
|
const expected = '123 Service Rd., Box 4, Columbus, 12345';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.serviceLocationFullAddress;
|
const text = wrapper.vm.serviceLocationFullAddress;
|
||||||
|
|
@ -624,7 +624,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = '123 Service Rd., Box 4,<br/> Columbus, OH ';
|
const expected = '123 Service Rd., Box 4, Columbus, OH ';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.serviceLocationFullAddress;
|
const text = wrapper.vm.serviceLocationFullAddress;
|
||||||
|
|
@ -642,7 +642,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = ', <br/> , ';
|
const expected = ', , ';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.serviceLocationFullAddress;
|
const text = wrapper.vm.serviceLocationFullAddress;
|
||||||
|
|
@ -675,7 +675,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = '304 Provider Ln.,<br/> Pittsburg, PA 16001';
|
const expected = '304 Provider Ln., Pittsburg, PA 16001';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.providerFullAddress;
|
const text = wrapper.vm.providerFullAddress;
|
||||||
|
|
@ -703,7 +703,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = '304 Provider Ln.,<br/> , PA 16001';
|
const expected = '304 Provider Ln., , PA 16001';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.providerFullAddress;
|
const text = wrapper.vm.providerFullAddress;
|
||||||
|
|
@ -717,7 +717,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = '304 Provider Ln.,<br/> Pittsburg, 16001';
|
const expected = '304 Provider Ln., Pittsburg, 16001';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.providerFullAddress;
|
const text = wrapper.vm.providerFullAddress;
|
||||||
|
|
@ -731,7 +731,7 @@ describe('OrderConfirmation.vue', () => {
|
||||||
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
useMainStore().getSubmittedOrder = jest.fn().mockImplementation(() => order);
|
||||||
};
|
};
|
||||||
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
const { wrapper } = getMountedComponent({}, {}, mockStoreActions);
|
||||||
const expected = '304 Provider Ln.,<br/> Pittsburg, PA ';
|
const expected = '304 Provider Ln., Pittsburg, PA ';
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const text = wrapper.vm.providerFullAddress;
|
const text = wrapper.vm.providerFullAddress;
|
||||||
|
|
@ -956,9 +956,9 @@ describe('OrderConfirmation.vue', () => {
|
||||||
describe('Methods', () => {
|
describe('Methods', () => {
|
||||||
describe('formatDate', () => {
|
describe('formatDate', () => {
|
||||||
test.each([
|
test.each([
|
||||||
['Wednesday, April 22', '2020-04-22'],
|
['Wednesday, April 22, 2020', '2020-04-22'],
|
||||||
['Thursday, February 1', '2018-02-01'],
|
['Thursday, February 1, 2018', '2018-02-01'],
|
||||||
['Wednesday, December 30', '2026-12-30']
|
['Wednesday, December 30, 2026', '2026-12-30']
|
||||||
])('returns %p given %p', (expected, date) => {
|
])('returns %p given %p', (expected, date) => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const order = deepClone(sessionStorage);
|
const order = deepClone(sessionStorage);
|
||||||
|
|
|
||||||
|
|
@ -422,7 +422,7 @@ export default {
|
||||||
|
|
||||||
// settleTenderAmount always shows 0 via localhost or dev.
|
// settleTenderAmount always shows 0 via localhost or dev.
|
||||||
// Temporarily set return true to see cart in localhost or dev environment
|
// Temporarily set return true to see cart in localhost or dev environment
|
||||||
return true;
|
return false;
|
||||||
},
|
},
|
||||||
displayWipers() {
|
displayWipers() {
|
||||||
const hasWiperPart = this.submittedOrder.lineItems.vaps.some((part) => part.partType.toLowerCase().includes('wiper'));
|
const hasWiperPart = this.submittedOrder.lineItems.vaps.some((part) => part.partType.toLowerCase().includes('wiper'));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue