Add Tests
Fix some tests for coverage statement
This commit is contained in:
parent
16296c7423
commit
bac22fe50a
3 changed files with 287 additions and 277 deletions
|
|
@ -83,7 +83,7 @@ function getMountedComponent(mainInitialState = {}, initialData = {}, methodToRu
|
||||||
return { wrapper };
|
return { wrapper };
|
||||||
}
|
}
|
||||||
|
|
||||||
describe.skip('coverageStatement.vue', () => {
|
describe('coverageStatement.vue', () => {
|
||||||
describe('method arePagePrerequisitesValid...', () => {
|
describe('method arePagePrerequisitesValid...', () => {
|
||||||
test('Should return true for valid page requisites if vin exists', () => {
|
test('Should return true for valid page requisites if vin exists', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -171,6 +171,64 @@ describe.skip('coverageStatement.vue', () => {
|
||||||
expect(footer.exists()).toBe(true);
|
expect(footer.exists()).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('ADAS', () => {
|
||||||
|
test('if Replace and parts require recalibration, isADAS should return true', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: false
|
||||||
|
},
|
||||||
|
lineItems: {
|
||||||
|
glassParts: [
|
||||||
|
{
|
||||||
|
requiresRecalibration: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.isADAS).toBeTruthy();
|
||||||
|
});
|
||||||
|
test('if Replace and parts do not require recalibration, isADAS should return false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: false
|
||||||
|
},
|
||||||
|
lineItems: {
|
||||||
|
glassParts: [
|
||||||
|
{
|
||||||
|
requiresRecalibration: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.isADAS).toBeFalsy();
|
||||||
|
});
|
||||||
|
test('if Repair, isADAS should return true', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.isADAS).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('Verified ITAC scenario', () => {
|
describe('Verified ITAC scenario', () => {
|
||||||
test('If policy lookup successful, not No Comp, and deductible > service price, verifiedITAC returns true', () => {
|
test('If policy lookup successful, not No Comp, and deductible > service price, verifiedITAC returns true', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -371,43 +429,6 @@ describe.skip('coverageStatement.vue', () => {
|
||||||
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
expect(wrapper.vm.verifiedDeductible).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('No Comp scenario', () => {
|
|
||||||
test('If noCoverage = true, verifiedNoComp returns true', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: true,
|
|
||||||
policyLookupSuccessful: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedNoComp).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('If noCoverage = false, verifiedNoComp returns false', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
},
|
|
||||||
policy: {
|
|
||||||
noCoverage: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.verifiedNoComp).toBeFalsy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('Unverified scenario', () => {
|
describe('Unverified scenario', () => {
|
||||||
test('If policyLookupSuccessful false, unverified returns true', () => {
|
test('If policyLookupSuccessful false, unverified returns true', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -444,7 +465,63 @@ describe.skip('coverageStatement.vue', () => {
|
||||||
expect(wrapper.vm.unverified).toBeFalsy();
|
expect(wrapper.vm.unverified).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('No Comp scenario', () => {
|
||||||
|
test('If noCoverage = true, verifiedNoComp returns true', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: true,
|
||||||
|
policyLookupSuccessful: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
const moqVerifiedNoComp = wrapper.vm.verifiedNoComp;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(moqVerifiedNoComp).toBe(true);
|
||||||
|
});
|
||||||
|
test('If noCoverage = false, verifiedNoComp returns false', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
damage: {
|
||||||
|
isRepair: true
|
||||||
|
},
|
||||||
|
policy: {
|
||||||
|
noCoverage: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.verifiedNoComp).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('Navigation', () => {
|
describe('Navigation', () => {
|
||||||
|
test('Function called on any FORWARD navigation', () => {
|
||||||
|
// Arrange
|
||||||
|
const mainInitialState = {
|
||||||
|
order: {
|
||||||
|
policy: {
|
||||||
|
isITAC: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { wrapper } = getMountedComponent(mainInitialState);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.mainStore.updatePolicyITACFlag)
|
||||||
|
.toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
test('If Unverified, navigate forward with CLICKED_FORWARD scenario', () => {
|
test('If Unverified, navigate forward with CLICKED_FORWARD scenario', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const mainInitialState = {
|
const mainInitialState = {
|
||||||
|
|
@ -676,64 +753,6 @@ describe.skip('coverageStatement.vue', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('ADAS', () => {
|
|
||||||
test('if Replace and parts require recalibration, isADAS should return true', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: false
|
|
||||||
},
|
|
||||||
lineItems: {
|
|
||||||
glassParts: [
|
|
||||||
{
|
|
||||||
requiresRecalibration: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.isADAS).toBeTruthy();
|
|
||||||
});
|
|
||||||
test('if Replace and parts do not require recalibration, isADAS should return false', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: false
|
|
||||||
},
|
|
||||||
lineItems: {
|
|
||||||
glassParts: [
|
|
||||||
{
|
|
||||||
requiresRecalibration: false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.isADAS).toBeFalsy();
|
|
||||||
});
|
|
||||||
test('if Repair, isADAS should return true', () => {
|
|
||||||
// Arrange
|
|
||||||
const mainInitialState = {
|
|
||||||
order: {
|
|
||||||
damage: {
|
|
||||||
isRepair: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const { wrapper } = getMountedComponent(mainInitialState);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.isADAS).toBeFalsy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('claim registration api call', () => {
|
describe('claim registration api call', () => {
|
||||||
it('claim registration not required => method not called', async () => {
|
it('claim registration not required => method not called', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
|
|
@ -746,7 +765,11 @@ describe.skip('coverageStatement.vue', () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.mainStore.registerClaim).not.toHaveBeenCalled();
|
expect(wrapper.vm.mainStore.registerClaim).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe.skip('coverageStatement.vue-broken', () => {
|
||||||
|
describe('claim registration api call', () => {
|
||||||
it.only('claim registration required => register claim method called', async () => {
|
it.only('claim registration required => register claim method called', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const sellingPrice = getRandomInt(50, 100);
|
const sellingPrice = getRandomInt(50, 100);
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
// Import Component
|
// Import Component
|
||||||
import { Form } from 'vee-validate';
|
import { Form, defineRule } from 'vee-validate';
|
||||||
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
|
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
|
||||||
import siteHeader from '@/iss-components/site-header/site-header.vue';
|
import siteHeader from '@/iss-components/site-header/site-header.vue';
|
||||||
import recalModal from '@/layouts/coverage-statement/recal-modal/recal-modal.vue';
|
import recalModal from '@/layouts/coverage-statement/recal-modal/recal-modal.vue';
|
||||||
|
|
@ -122,6 +122,10 @@ import globalRules from '@/constants/global-rules.js';
|
||||||
import baseFormMixin from '@/mixins/base-form-mixin.js';
|
import baseFormMixin from '@/mixins/base-form-mixin.js';
|
||||||
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
import navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||||
import routerParams from '@/router/router-constants/router-params';
|
import routerParams from '@/router/router-constants/router-params';
|
||||||
|
import { required } from '@/helpers/validation-rules';
|
||||||
|
import errorMessages from '@/constants/error-messages';
|
||||||
|
|
||||||
|
defineRule('option-required', required(errorMessages.OPTION_REQUIRED));
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'coverage-statement',
|
name: 'coverage-statement',
|
||||||
|
|
|
||||||
|
|
@ -492,16 +492,14 @@ describe('Store', () => {
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
method: endpoints.SaveSession.method,
|
||||||
method: endpoints.SaveSession.method,
|
endpoint: endpoints.SaveSession.url
|
||||||
endpoint: endpoints.SaveSession.url
|
}));
|
||||||
}
|
|
||||||
));
|
|
||||||
});
|
});
|
||||||
it('Returns expected response object', async () => {
|
it('Returns expected response object', async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var response = { ReferralNumber: getRandomString(6, 6) };
|
const response = { ReferralNumber: getRandomString(6, 6) };
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -509,10 +507,10 @@ describe('Store', () => {
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
await expect(result).resolves.toBe(response);
|
await expect(result).resolves.toBe(response);
|
||||||
})
|
});
|
||||||
it('calls api with expected application user data', () => {
|
it('calls api with expected application user data', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var applicationUser = {
|
const applicationUser = {
|
||||||
crmCustomerId: getRandomString(6, 6),
|
crmCustomerId: getRandomString(6, 6),
|
||||||
experiments: getRandomString(6, 6),
|
experiments: getRandomString(6, 6),
|
||||||
lastPageVisited: getRandomString(6, 6),
|
lastPageVisited: getRandomString(6, 6),
|
||||||
|
|
@ -526,22 +524,20 @@ describe('Store', () => {
|
||||||
const result = store.saveSession();
|
const result = store.saveSession();
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
applicationUser: expect.objectContaining({
|
||||||
applicationUser: expect.objectContaining({
|
crmCustomerId: applicationUser.crmCustomerId,
|
||||||
crmCustomerId: applicationUser.crmCustomerId,
|
experiments: applicationUser.experiments,
|
||||||
experiments: applicationUser.experiments,
|
lastPage: applicationUser.lastPageVisited,
|
||||||
lastPage: applicationUser.lastPageVisited,
|
pageData: applicationUser.pageData,
|
||||||
pageData: applicationUser.pageData,
|
savedSessionId: applicationUser.savedSessionId
|
||||||
savedSessionId: applicationUser.savedSessionId
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('calls api with expected vehicle', () => {
|
it('calls api with expected vehicle', () => {
|
||||||
var vehicle = {
|
const vehicle = {
|
||||||
year: getRandomString(6, 6),
|
year: getRandomString(6, 6),
|
||||||
make: getRandomString(6, 6),
|
make: getRandomString(6, 6),
|
||||||
model: getRandomString(6, 6),
|
model: getRandomString(6, 6),
|
||||||
|
|
@ -557,25 +553,23 @@ describe('Store', () => {
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
vehicle: expect.objectContaining({
|
||||||
vehicle: expect.objectContaining({
|
year: vehicle.year,
|
||||||
year: vehicle.year,
|
make: vehicle.make,
|
||||||
make: vehicle.make,
|
model: vehicle.model,
|
||||||
model: vehicle.model,
|
style: vehicle.style,
|
||||||
style: vehicle.style,
|
carId: vehicle.carId,
|
||||||
carId: vehicle.carId,
|
vin: vehicle.vin,
|
||||||
vin: vehicle.vin,
|
licensePlateNumber: vehicle.registration.licensePlate
|
||||||
licensePlateNumber: vehicle.registration.licensePlate
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
})
|
||||||
));
|
}));
|
||||||
});
|
});
|
||||||
it('calls api with expected damage', () => {
|
it('calls api with expected damage', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var damage = {
|
const damage = {
|
||||||
isRepair: getRandomString(6, 6),
|
isRepair: getRandomString(6, 6),
|
||||||
numberOfChips: getRandomString(6, 6),
|
numberOfChips: getRandomString(6, 6),
|
||||||
glassToReplace: [],
|
glassToReplace: [],
|
||||||
|
|
@ -583,7 +577,7 @@ describe('Store', () => {
|
||||||
moldingQuestionAnswers: getRandomString(6, 6),
|
moldingQuestionAnswers: getRandomString(6, 6),
|
||||||
capabilityQuestionAnswers: getRandomString(6, 6)
|
capabilityQuestionAnswers: getRandomString(6, 6)
|
||||||
};
|
};
|
||||||
var policy = {
|
const policy = {
|
||||||
dateOfLoss: getRandomString(6, 6),
|
dateOfLoss: getRandomString(6, 6),
|
||||||
damageCause: getRandomString(6, 6),
|
damageCause: getRandomString(6, 6),
|
||||||
damageState: getRandomString(6, 6),
|
damageState: getRandomString(6, 6),
|
||||||
|
|
@ -598,41 +592,39 @@ describe('Store', () => {
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
damage: expect.objectContaining({
|
||||||
damage: expect.objectContaining({
|
numberOfChips: damage.numberOfChips,
|
||||||
numberOfChips: damage.numberOfChips,
|
isRepair: damage.isRepair,
|
||||||
isRepair: damage.isRepair,
|
partQuestionAnswers: damage.partQuestionAnswers,
|
||||||
partQuestionAnswers: damage.partQuestionAnswers,
|
moldingQuestionAnswers: damage.moldingQuestionAnswers,
|
||||||
moldingQuestionAnswers: damage.moldingQuestionAnswers,
|
capabilityQuestionAnswers: damage.capabilityQuestionAnswers,
|
||||||
capabilityQuestionAnswers: damage.capabilityQuestionAnswers,
|
dateOfLoss: policy.dateOfLoss,
|
||||||
dateOfLoss: policy.dateOfLoss,
|
damageCause: policy.damageCause,
|
||||||
damageCause: policy.damageCause,
|
damageState: policy.damageState,
|
||||||
damageState: policy.damageState,
|
damageCity: policy.damageCity,
|
||||||
damageCity: policy.damageCity,
|
isDamageGlassOnly: policy.isDamageGlassOnly
|
||||||
isDamageGlassOnly: policy.isDamageGlassOnly
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('calls api with expected policy', () => {
|
it('calls api with expected policy', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var customer = {
|
const customer = {
|
||||||
firstName: getRandomString(6, 6),
|
firstName: getRandomString(6, 6),
|
||||||
lastName: getRandomString(6, 6),
|
lastName: getRandomString(6, 6),
|
||||||
emailAddress: getRandomString(6, 6),
|
emailAddress: getRandomString(6, 6),
|
||||||
phoneNumber: getRandomString(6, 6)
|
phoneNumber: getRandomString(6, 6)
|
||||||
};
|
};
|
||||||
var policy = {
|
const policy = {
|
||||||
policyNumber: getRandomString(6, 6),
|
policyNumber: getRandomString(6, 6),
|
||||||
policyZipCode: getRandomString(6, 6),
|
policyZipCode: getRandomString(6, 6),
|
||||||
policyLookupSuccessful: getRandomString(6, 6),
|
policyLookupSuccessful: getRandomString(6, 6),
|
||||||
noCoverage: getRandomString(6, 6)
|
noCoverage: getRandomString(6, 6)
|
||||||
};
|
};
|
||||||
var originalDeductible = getRandomString(6, 6);
|
const originalDeductible = getRandomString(6, 6);
|
||||||
var currentDeductible = getRandomString(6, 6);
|
const currentDeductible = getRandomString(6, 6);
|
||||||
store.order.originalDeductible = originalDeductible;
|
store.order.originalDeductible = originalDeductible;
|
||||||
store.order.currentDeductible = currentDeductible;
|
store.order.currentDeductible = currentDeductible;
|
||||||
store.order.customer = customer;
|
store.order.customer = customer;
|
||||||
|
|
@ -643,30 +635,28 @@ describe('Store', () => {
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
policy: expect.objectContaining({
|
||||||
policy: expect.objectContaining({
|
policyHolder: expect.objectContaining({
|
||||||
policyHolder: expect.objectContaining({
|
policyFirstName: customer.firstName,
|
||||||
policyFirstName: customer.firstName,
|
policyLastName: customer.lastName,
|
||||||
policyLastName: customer.lastName,
|
policyPhoneNumber: customer.phoneNumber,
|
||||||
policyPhoneNumber: customer.phoneNumber,
|
policyEmail: customer.emailAddress
|
||||||
policyEmail: customer.emailAddress
|
}),
|
||||||
}),
|
policyNumber: policy.policyNumber,
|
||||||
policyNumber: policy.policyNumber,
|
policyZipCode: policy.policyZipCode,
|
||||||
policyZipCode: policy.policyZipCode,
|
noCoverage: policy.noCoverage,
|
||||||
noCoverage: policy.noCoverage,
|
policyLookupSuccessful: policy.policyLookupSuccessful,
|
||||||
policyLookupSuccessful: policy.policyLookupSuccessful,
|
originalDeductible,
|
||||||
originalDeductible,
|
currentDeductible
|
||||||
currentDeductible
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('calls api with expected customer', () => {
|
it('calls api with expected customer', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var customer = {
|
const customer = {
|
||||||
address: {
|
address: {
|
||||||
streetAddress: getRandomString(6, 6),
|
streetAddress: getRandomString(6, 6),
|
||||||
streetAddress2: getRandomString(6, 6),
|
streetAddress2: getRandomString(6, 6),
|
||||||
|
|
@ -675,7 +665,7 @@ describe('Store', () => {
|
||||||
zipCode: getRandomString(6, 6)
|
zipCode: getRandomString(6, 6)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var contactInfo = {
|
const contactInfo = {
|
||||||
firstName: getRandomString(6, 6),
|
firstName: getRandomString(6, 6),
|
||||||
lastName: getRandomString(6, 6),
|
lastName: getRandomString(6, 6),
|
||||||
emailAddress: getRandomString(6, 6),
|
emailAddress: getRandomString(6, 6),
|
||||||
|
|
@ -690,30 +680,28 @@ describe('Store', () => {
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
customer: expect.objectContaining({
|
||||||
customer: expect.objectContaining({
|
address: expect.objectContaining({
|
||||||
address: expect.objectContaining({
|
streetAddress: customer.address.streetAddress,
|
||||||
streetAddress: customer.address.streetAddress,
|
streetAddress2: customer.address.streetAddress2,
|
||||||
streetAddress2: customer.address.streetAddress2,
|
city: customer.address.city,
|
||||||
city: customer.address.city,
|
state: customer.address.state,
|
||||||
state: customer.address.state,
|
zipCode: customer.address.zipCode
|
||||||
zipCode: customer.address.zipCode
|
}),
|
||||||
}),
|
emailAddress: contactInfo.emailAddress,
|
||||||
emailAddress: contactInfo.emailAddress,
|
firstName: contactInfo.firstName,
|
||||||
firstName: contactInfo.firstName,
|
lastName: contactInfo.lastName,
|
||||||
lastName: contactInfo.lastName,
|
phoneNumber: contactInfo.phoneNumber,
|
||||||
phoneNumber: contactInfo.phoneNumber,
|
optInSms: contactInfo.requestTextUpdates
|
||||||
optInSms: contactInfo.requestTextUpdates
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('calls api with expected lineItems', () => {
|
it('calls api with expected lineItems', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var lineItems = {
|
const lineItems = {
|
||||||
glassParts: getRandomString(6, 6),
|
glassParts: getRandomString(6, 6),
|
||||||
supportingItems: getRandomString(6, 6),
|
supportingItems: getRandomString(6, 6),
|
||||||
vaps: getRandomString(6, 6)
|
vaps: getRandomString(6, 6)
|
||||||
|
|
@ -725,17 +713,15 @@ describe('Store', () => {
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
lineItems: expect.objectContaining({
|
||||||
lineItems: expect.objectContaining({
|
glassParts: lineItems.glassParts,
|
||||||
glassParts: lineItems.glassParts,
|
supportingItems: lineItems.supportingItems,
|
||||||
supportingItems: lineItems.supportingItems,
|
vaps: lineItems.vaps
|
||||||
vaps: lineItems.vaps
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it.each([
|
it.each([
|
||||||
[coverageStatuses.PENDING],
|
[coverageStatuses.PENDING],
|
||||||
|
|
@ -772,12 +758,12 @@ describe('Store', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('calls api with expected service location', () => {
|
it('calls api with expected service location', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var notesForTechnician = getRandomString(6, 6);
|
const notesForTechnician = getRandomString(6, 6);
|
||||||
var serviceLocation = {
|
const serviceLocation = {
|
||||||
address: getRandomString(6, 6),
|
address: getRandomString(6, 6),
|
||||||
city: getRandomString(6, 6),
|
city: getRandomString(6, 6),
|
||||||
state: getRandomString(6, 6),
|
state: getRandomString(6, 6),
|
||||||
|
|
@ -792,26 +778,24 @@ describe('Store', () => {
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
serviceLocation: expect.objectContaining({
|
||||||
serviceLocation: expect.objectContaining({
|
address: expect.objectContaining({
|
||||||
address: expect.objectContaining({
|
streetAddress: serviceLocation.address,
|
||||||
streetAddress: serviceLocation.address,
|
city: serviceLocation.city,
|
||||||
city: serviceLocation.city,
|
state: serviceLocation.state,
|
||||||
state: serviceLocation.state,
|
zipCode: serviceLocation.zipCode,
|
||||||
zipCode: serviceLocation.zipCode,
|
zipCodeCtu: serviceLocation.zipCodeCtu
|
||||||
zipCodeCtu: serviceLocation.zipCodeCtu
|
}),
|
||||||
}),
|
techNotes: notesForTechnician
|
||||||
techNotes: notesForTechnician
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('calls api with expected schedule', () => {
|
it('calls api with expected schedule', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var schedule = {
|
const schedule = {
|
||||||
date: getRandomString(6, 6),
|
date: getRandomString(6, 6),
|
||||||
startTime: getRandomString(6, 6),
|
startTime: getRandomString(6, 6),
|
||||||
endTime: getRandomString(6, 6),
|
endTime: getRandomString(6, 6),
|
||||||
|
|
@ -825,51 +809,45 @@ describe('Store', () => {
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
schedule: expect.objectContaining({
|
||||||
schedule: expect.objectContaining({
|
date: schedule.date,
|
||||||
date: schedule.date,
|
startTime: schedule.startTime,
|
||||||
startTime: schedule.startTime,
|
endTime: schedule.endTime,
|
||||||
endTime: schedule.endTime,
|
routeCode: schedule.routeCode,
|
||||||
routeCode: schedule.routeCode,
|
jobMaxMinutes: schedule.jobMaxMinutes
|
||||||
jobMaxMinutes: schedule.jobMaxMinutes
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('calls api with expected referral date', () => {
|
it('calls api with expected referral date', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var referralDate = getRandomString(6, 6);
|
const referralDate = getRandomString(6, 6);
|
||||||
store.order.referralDate = referralDate;
|
store.order.referralDate = referralDate;
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({ referralDate })
|
||||||
payload: expect.objectContaining({ referralDate: referralDate })
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('calls api with expected referral number', () => {
|
it('calls api with expected referral number', () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
var referralNumber = getRandomString(6, 6);
|
const referralNumber = getRandomString(6, 6);
|
||||||
store.order.referralNumber = referralNumber;
|
store.order.referralNumber = referralNumber;
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
store.saveSession();
|
store.saveSession();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({ referralNumber })
|
||||||
payload: expect.objectContaining({ referralNumber: referralNumber })
|
}));
|
||||||
}
|
|
||||||
));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('No glassArray => empty list', async () => {
|
it('No glassArray => empty list', async () => {
|
||||||
|
|
@ -880,15 +858,13 @@ describe('Store', () => {
|
||||||
await store.saveSession();
|
await store.saveSession();
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
damage: expect.objectContaining({
|
||||||
damage: expect.objectContaining({
|
glassToReplace: []
|
||||||
glassToReplace: []
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('glassArray empty => empty list', async () => {
|
it('glassArray empty => empty list', async () => {
|
||||||
store.damage.glassToReplace = [];
|
store.damage.glassToReplace = [];
|
||||||
|
|
@ -898,15 +874,13 @@ describe('Store', () => {
|
||||||
await store.saveSession();
|
await store.saveSession();
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
damage: expect.objectContaining({
|
||||||
damage: expect.objectContaining({
|
glassToReplace: []
|
||||||
glassToReplace: []
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('Nonempty glass array => expected glass array sent', async () => {
|
it('Nonempty glass array => expected glass array sent', async () => {
|
||||||
const location1 = getRandomString(5);
|
const location1 = getRandomString(5);
|
||||||
|
|
@ -914,8 +888,8 @@ describe('Store', () => {
|
||||||
const name1 = getRandomString(10);
|
const name1 = getRandomString(10);
|
||||||
const name2 = getRandomString(10);
|
const name2 = getRandomString(10);
|
||||||
store.damage.glassToReplace = [
|
store.damage.glassToReplace = [
|
||||||
{glassLocation: location1, glassName: name1},
|
{ glassLocation: location1, glassName: name1 },
|
||||||
{glassLocation: location2, glassName: name2}
|
{ glassLocation: location2, glassName: name2 }
|
||||||
],
|
],
|
||||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||||
|
|
||||||
|
|
@ -923,18 +897,16 @@ describe('Store', () => {
|
||||||
await store.saveSession();
|
await store.saveSession();
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
payload: expect.objectContaining({
|
||||||
payload: expect.objectContaining({
|
damage: expect.objectContaining({
|
||||||
damage: expect.objectContaining({
|
glassToReplace: expect.arrayContaining([
|
||||||
glassToReplace: expect.arrayContaining([
|
{ location: location1, name: name1 },
|
||||||
{location: location1, name: name1},
|
{ location: location2, name: name2 }
|
||||||
{location: location2, name: name2}
|
])
|
||||||
])
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
}));
|
||||||
});
|
});
|
||||||
it('api call throws exception', async () => {
|
it('api call throws exception', async () => {
|
||||||
expect.assertions(2);
|
expect.assertions(2);
|
||||||
|
|
@ -947,12 +919,10 @@ describe('Store', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Asserts
|
// Asserts
|
||||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||||
{
|
method: endpoints.SaveSession.method,
|
||||||
method: endpoints.SaveSession.method,
|
endpoint: endpoints.SaveSession.url
|
||||||
endpoint: endpoints.SaveSession.url
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1023,4 +993,17 @@ describe('Store', () => {
|
||||||
expect(store.applicationUser.duplicateOrders.length).toBe(0);
|
expect(store.applicationUser.duplicateOrders.length).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('updatePolicyITACFlag method', () => {
|
||||||
|
it('updatePolicyITACFlag updates policy.isITAC flag in store', () => {
|
||||||
|
// Assert
|
||||||
|
const moqIsITAC = getRandomBoolean();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
store.updatePolicyITACFlag(moqIsITAC);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(store.order.policy.isITAC).toEqual(moqIsITAC);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue