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,8 +524,7 @@ 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,
|
||||||
|
|
@ -537,11 +534,10 @@ describe('Store', () => {
|
||||||
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,8 +553,7 @@ 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,
|
||||||
|
|
@ -570,12 +565,11 @@ describe('Store', () => {
|
||||||
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,8 +592,7 @@ 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,
|
||||||
|
|
@ -614,25 +607,24 @@ describe('Store', () => {
|
||||||
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,8 +635,7 @@ 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({
|
||||||
|
|
@ -661,12 +652,11 @@ describe('Store', () => {
|
||||||
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,8 +680,7 @@ 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({
|
||||||
|
|
@ -708,12 +697,11 @@ describe('Store', () => {
|
||||||
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,8 +713,7 @@ 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,
|
||||||
|
|
@ -734,8 +721,7 @@ describe('Store', () => {
|
||||||
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,8 +778,7 @@ 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({
|
||||||
|
|
@ -806,12 +791,11 @@ describe('Store', () => {
|
||||||
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,8 +809,7 @@ 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,
|
||||||
|
|
@ -836,12 +819,11 @@ describe('Store', () => {
|
||||||
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({}));
|
||||||
|
|
||||||
|
|
@ -849,15 +831,13 @@ describe('Store', () => {
|
||||||
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({}));
|
||||||
|
|
||||||
|
|
@ -865,11 +845,9 @@ describe('Store', () => {
|
||||||
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);
|
||||||
|
|
@ -923,8 +897,7 @@ 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([
|
||||||
|
|
@ -933,8 +906,7 @@ describe('Store', () => {
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
});
|
});
|
||||||
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