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 };
|
||||
}
|
||||
|
||||
describe.skip('coverageStatement.vue', () => {
|
||||
describe('coverageStatement.vue', () => {
|
||||
describe('method arePagePrerequisitesValid...', () => {
|
||||
test('Should return true for valid page requisites if vin exists', () => {
|
||||
// Arrange
|
||||
|
|
@ -171,6 +171,64 @@ describe.skip('coverageStatement.vue', () => {
|
|||
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', () => {
|
||||
test('If policy lookup successful, not No Comp, and deductible > service price, verifiedITAC returns true', () => {
|
||||
// Arrange
|
||||
|
|
@ -371,43 +429,6 @@ describe.skip('coverageStatement.vue', () => {
|
|||
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', () => {
|
||||
test('If policyLookupSuccessful false, unverified returns true', () => {
|
||||
// Arrange
|
||||
|
|
@ -444,7 +465,63 @@ describe.skip('coverageStatement.vue', () => {
|
|||
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', () => {
|
||||
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', () => {
|
||||
// Arrange
|
||||
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', () => {
|
||||
it('claim registration not required => method not called', async () => {
|
||||
// Arrange
|
||||
|
|
@ -746,7 +765,11 @@ describe.skip('coverageStatement.vue', () => {
|
|||
// Assert
|
||||
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 () => {
|
||||
// Arrange
|
||||
const sellingPrice = getRandomInt(50, 100);
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@
|
|||
<script>
|
||||
|
||||
// Import Component
|
||||
import { Form } from 'vee-validate';
|
||||
import { Form, defineRule } from 'vee-validate';
|
||||
import siteFooter from '@/iss-components/site-footer/site-footer.vue';
|
||||
import siteHeader from '@/iss-components/site-header/site-header.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 navigationScenarios from '@/router/router-constants/navigation-scenarios.js';
|
||||
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 {
|
||||
name: 'coverage-statement',
|
||||
|
|
|
|||
|
|
@ -492,16 +492,14 @@ describe('Store', () => {
|
|||
store.saveSession();
|
||||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
method: endpoints.SaveSession.method,
|
||||
endpoint: endpoints.SaveSession.url
|
||||
}
|
||||
));
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
method: endpoints.SaveSession.method,
|
||||
endpoint: endpoints.SaveSession.url
|
||||
}));
|
||||
});
|
||||
it('Returns expected response object', async () => {
|
||||
// Arrange
|
||||
var response = { ReferralNumber: getRandomString(6, 6) };
|
||||
const response = { ReferralNumber: getRandomString(6, 6) };
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve(response));
|
||||
|
||||
// Act
|
||||
|
|
@ -509,10 +507,10 @@ describe('Store', () => {
|
|||
|
||||
// Asserts
|
||||
await expect(result).resolves.toBe(response);
|
||||
})
|
||||
});
|
||||
it('calls api with expected application user data', () => {
|
||||
// Arrange
|
||||
var applicationUser = {
|
||||
const applicationUser = {
|
||||
crmCustomerId: getRandomString(6, 6),
|
||||
experiments: getRandomString(6, 6),
|
||||
lastPageVisited: getRandomString(6, 6),
|
||||
|
|
@ -526,22 +524,20 @@ describe('Store', () => {
|
|||
const result = store.saveSession();
|
||||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
applicationUser: expect.objectContaining({
|
||||
crmCustomerId: applicationUser.crmCustomerId,
|
||||
experiments: applicationUser.experiments,
|
||||
lastPage: applicationUser.lastPageVisited,
|
||||
pageData: applicationUser.pageData,
|
||||
savedSessionId: applicationUser.savedSessionId
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
applicationUser: expect.objectContaining({
|
||||
crmCustomerId: applicationUser.crmCustomerId,
|
||||
experiments: applicationUser.experiments,
|
||||
lastPage: applicationUser.lastPageVisited,
|
||||
pageData: applicationUser.pageData,
|
||||
savedSessionId: applicationUser.savedSessionId
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('calls api with expected vehicle', () => {
|
||||
var vehicle = {
|
||||
const vehicle = {
|
||||
year: getRandomString(6, 6),
|
||||
make: getRandomString(6, 6),
|
||||
model: getRandomString(6, 6),
|
||||
|
|
@ -557,25 +553,23 @@ describe('Store', () => {
|
|||
store.saveSession();
|
||||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
vehicle: expect.objectContaining({
|
||||
year: vehicle.year,
|
||||
make: vehicle.make,
|
||||
model: vehicle.model,
|
||||
style: vehicle.style,
|
||||
carId: vehicle.carId,
|
||||
vin: vehicle.vin,
|
||||
licensePlateNumber: vehicle.registration.licensePlate
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
vehicle: expect.objectContaining({
|
||||
year: vehicle.year,
|
||||
make: vehicle.make,
|
||||
model: vehicle.model,
|
||||
style: vehicle.style,
|
||||
carId: vehicle.carId,
|
||||
vin: vehicle.vin,
|
||||
licensePlateNumber: vehicle.registration.licensePlate
|
||||
})
|
||||
}
|
||||
));
|
||||
})
|
||||
}));
|
||||
});
|
||||
it('calls api with expected damage', () => {
|
||||
// Arrange
|
||||
var damage = {
|
||||
const damage = {
|
||||
isRepair: getRandomString(6, 6),
|
||||
numberOfChips: getRandomString(6, 6),
|
||||
glassToReplace: [],
|
||||
|
|
@ -583,7 +577,7 @@ describe('Store', () => {
|
|||
moldingQuestionAnswers: getRandomString(6, 6),
|
||||
capabilityQuestionAnswers: getRandomString(6, 6)
|
||||
};
|
||||
var policy = {
|
||||
const policy = {
|
||||
dateOfLoss: getRandomString(6, 6),
|
||||
damageCause: getRandomString(6, 6),
|
||||
damageState: getRandomString(6, 6),
|
||||
|
|
@ -598,41 +592,39 @@ describe('Store', () => {
|
|||
store.saveSession();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
damage: expect.objectContaining({
|
||||
numberOfChips: damage.numberOfChips,
|
||||
isRepair: damage.isRepair,
|
||||
partQuestionAnswers: damage.partQuestionAnswers,
|
||||
moldingQuestionAnswers: damage.moldingQuestionAnswers,
|
||||
capabilityQuestionAnswers: damage.capabilityQuestionAnswers,
|
||||
dateOfLoss: policy.dateOfLoss,
|
||||
damageCause: policy.damageCause,
|
||||
damageState: policy.damageState,
|
||||
damageCity: policy.damageCity,
|
||||
isDamageGlassOnly: policy.isDamageGlassOnly
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
damage: expect.objectContaining({
|
||||
numberOfChips: damage.numberOfChips,
|
||||
isRepair: damage.isRepair,
|
||||
partQuestionAnswers: damage.partQuestionAnswers,
|
||||
moldingQuestionAnswers: damage.moldingQuestionAnswers,
|
||||
capabilityQuestionAnswers: damage.capabilityQuestionAnswers,
|
||||
dateOfLoss: policy.dateOfLoss,
|
||||
damageCause: policy.damageCause,
|
||||
damageState: policy.damageState,
|
||||
damageCity: policy.damageCity,
|
||||
isDamageGlassOnly: policy.isDamageGlassOnly
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('calls api with expected policy', () => {
|
||||
// Arrange
|
||||
var customer = {
|
||||
const customer = {
|
||||
firstName: getRandomString(6, 6),
|
||||
lastName: getRandomString(6, 6),
|
||||
emailAddress: getRandomString(6, 6),
|
||||
phoneNumber: getRandomString(6, 6)
|
||||
};
|
||||
var policy = {
|
||||
const policy = {
|
||||
policyNumber: getRandomString(6, 6),
|
||||
policyZipCode: getRandomString(6, 6),
|
||||
policyLookupSuccessful: getRandomString(6, 6),
|
||||
noCoverage: getRandomString(6, 6)
|
||||
};
|
||||
var originalDeductible = getRandomString(6, 6);
|
||||
var currentDeductible = getRandomString(6, 6);
|
||||
const originalDeductible = getRandomString(6, 6);
|
||||
const currentDeductible = getRandomString(6, 6);
|
||||
store.order.originalDeductible = originalDeductible;
|
||||
store.order.currentDeductible = currentDeductible;
|
||||
store.order.customer = customer;
|
||||
|
|
@ -643,30 +635,28 @@ describe('Store', () => {
|
|||
store.saveSession();
|
||||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
policy: expect.objectContaining({
|
||||
policyHolder: expect.objectContaining({
|
||||
policyFirstName: customer.firstName,
|
||||
policyLastName: customer.lastName,
|
||||
policyPhoneNumber: customer.phoneNumber,
|
||||
policyEmail: customer.emailAddress
|
||||
}),
|
||||
policyNumber: policy.policyNumber,
|
||||
policyZipCode: policy.policyZipCode,
|
||||
noCoverage: policy.noCoverage,
|
||||
policyLookupSuccessful: policy.policyLookupSuccessful,
|
||||
originalDeductible,
|
||||
currentDeductible
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
policy: expect.objectContaining({
|
||||
policyHolder: expect.objectContaining({
|
||||
policyFirstName: customer.firstName,
|
||||
policyLastName: customer.lastName,
|
||||
policyPhoneNumber: customer.phoneNumber,
|
||||
policyEmail: customer.emailAddress
|
||||
}),
|
||||
policyNumber: policy.policyNumber,
|
||||
policyZipCode: policy.policyZipCode,
|
||||
noCoverage: policy.noCoverage,
|
||||
policyLookupSuccessful: policy.policyLookupSuccessful,
|
||||
originalDeductible,
|
||||
currentDeductible
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('calls api with expected customer', () => {
|
||||
// Arrange
|
||||
var customer = {
|
||||
const customer = {
|
||||
address: {
|
||||
streetAddress: getRandomString(6, 6),
|
||||
streetAddress2: getRandomString(6, 6),
|
||||
|
|
@ -675,7 +665,7 @@ describe('Store', () => {
|
|||
zipCode: getRandomString(6, 6)
|
||||
}
|
||||
};
|
||||
var contactInfo = {
|
||||
const contactInfo = {
|
||||
firstName: getRandomString(6, 6),
|
||||
lastName: getRandomString(6, 6),
|
||||
emailAddress: getRandomString(6, 6),
|
||||
|
|
@ -690,30 +680,28 @@ describe('Store', () => {
|
|||
store.saveSession();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
customer: expect.objectContaining({
|
||||
address: expect.objectContaining({
|
||||
streetAddress: customer.address.streetAddress,
|
||||
streetAddress2: customer.address.streetAddress2,
|
||||
city: customer.address.city,
|
||||
state: customer.address.state,
|
||||
zipCode: customer.address.zipCode
|
||||
}),
|
||||
emailAddress: contactInfo.emailAddress,
|
||||
firstName: contactInfo.firstName,
|
||||
lastName: contactInfo.lastName,
|
||||
phoneNumber: contactInfo.phoneNumber,
|
||||
optInSms: contactInfo.requestTextUpdates
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
customer: expect.objectContaining({
|
||||
address: expect.objectContaining({
|
||||
streetAddress: customer.address.streetAddress,
|
||||
streetAddress2: customer.address.streetAddress2,
|
||||
city: customer.address.city,
|
||||
state: customer.address.state,
|
||||
zipCode: customer.address.zipCode
|
||||
}),
|
||||
emailAddress: contactInfo.emailAddress,
|
||||
firstName: contactInfo.firstName,
|
||||
lastName: contactInfo.lastName,
|
||||
phoneNumber: contactInfo.phoneNumber,
|
||||
optInSms: contactInfo.requestTextUpdates
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('calls api with expected lineItems', () => {
|
||||
// Arrange
|
||||
var lineItems = {
|
||||
const lineItems = {
|
||||
glassParts: getRandomString(6, 6),
|
||||
supportingItems: getRandomString(6, 6),
|
||||
vaps: getRandomString(6, 6)
|
||||
|
|
@ -725,17 +713,15 @@ describe('Store', () => {
|
|||
store.saveSession();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
lineItems: expect.objectContaining({
|
||||
glassParts: lineItems.glassParts,
|
||||
supportingItems: lineItems.supportingItems,
|
||||
vaps: lineItems.vaps
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
lineItems: expect.objectContaining({
|
||||
glassParts: lineItems.glassParts,
|
||||
supportingItems: lineItems.supportingItems,
|
||||
vaps: lineItems.vaps
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it.each([
|
||||
[coverageStatuses.PENDING],
|
||||
|
|
@ -772,12 +758,12 @@ describe('Store', () => {
|
|||
})
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('calls api with expected service location', () => {
|
||||
// Arrange
|
||||
var notesForTechnician = getRandomString(6, 6);
|
||||
var serviceLocation = {
|
||||
const notesForTechnician = getRandomString(6, 6);
|
||||
const serviceLocation = {
|
||||
address: getRandomString(6, 6),
|
||||
city: getRandomString(6, 6),
|
||||
state: getRandomString(6, 6),
|
||||
|
|
@ -792,26 +778,24 @@ describe('Store', () => {
|
|||
store.saveSession();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
serviceLocation: expect.objectContaining({
|
||||
address: expect.objectContaining({
|
||||
streetAddress: serviceLocation.address,
|
||||
city: serviceLocation.city,
|
||||
state: serviceLocation.state,
|
||||
zipCode: serviceLocation.zipCode,
|
||||
zipCodeCtu: serviceLocation.zipCodeCtu
|
||||
}),
|
||||
techNotes: notesForTechnician
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
serviceLocation: expect.objectContaining({
|
||||
address: expect.objectContaining({
|
||||
streetAddress: serviceLocation.address,
|
||||
city: serviceLocation.city,
|
||||
state: serviceLocation.state,
|
||||
zipCode: serviceLocation.zipCode,
|
||||
zipCodeCtu: serviceLocation.zipCodeCtu
|
||||
}),
|
||||
techNotes: notesForTechnician
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('calls api with expected schedule', () => {
|
||||
// Arrange
|
||||
var schedule = {
|
||||
const schedule = {
|
||||
date: getRandomString(6, 6),
|
||||
startTime: getRandomString(6, 6),
|
||||
endTime: getRandomString(6, 6),
|
||||
|
|
@ -825,51 +809,45 @@ describe('Store', () => {
|
|||
store.saveSession();
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
schedule: expect.objectContaining({
|
||||
date: schedule.date,
|
||||
startTime: schedule.startTime,
|
||||
endTime: schedule.endTime,
|
||||
routeCode: schedule.routeCode,
|
||||
jobMaxMinutes: schedule.jobMaxMinutes
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
schedule: expect.objectContaining({
|
||||
date: schedule.date,
|
||||
startTime: schedule.startTime,
|
||||
endTime: schedule.endTime,
|
||||
routeCode: schedule.routeCode,
|
||||
jobMaxMinutes: schedule.jobMaxMinutes
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('calls api with expected referral date', () => {
|
||||
// Arrange
|
||||
var referralDate = getRandomString(6, 6);
|
||||
const referralDate = getRandomString(6, 6);
|
||||
store.order.referralDate = referralDate;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
store.saveSession();
|
||||
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({ referralDate: referralDate })
|
||||
})
|
||||
);
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({ referralDate })
|
||||
}));
|
||||
});
|
||||
it('calls api with expected referral number', () => {
|
||||
// Arrange
|
||||
var referralNumber = getRandomString(6, 6);
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
store.order.referralNumber = referralNumber;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
store.saveSession();
|
||||
|
||||
|
||||
// Assert
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({ referralNumber: referralNumber })
|
||||
}
|
||||
));
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({ referralNumber })
|
||||
}));
|
||||
});
|
||||
});
|
||||
it('No glassArray => empty list', async () => {
|
||||
|
|
@ -880,15 +858,13 @@ describe('Store', () => {
|
|||
await store.saveSession();
|
||||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
damage: expect.objectContaining({
|
||||
glassToReplace: []
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
damage: expect.objectContaining({
|
||||
glassToReplace: []
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('glassArray empty => empty list', async () => {
|
||||
store.damage.glassToReplace = [];
|
||||
|
|
@ -898,15 +874,13 @@ describe('Store', () => {
|
|||
await store.saveSession();
|
||||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
damage: expect.objectContaining({
|
||||
glassToReplace: []
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
damage: expect.objectContaining({
|
||||
glassToReplace: []
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('Nonempty glass array => expected glass array sent', async () => {
|
||||
const location1 = getRandomString(5);
|
||||
|
|
@ -914,8 +888,8 @@ describe('Store', () => {
|
|||
const name1 = getRandomString(10);
|
||||
const name2 = getRandomString(10);
|
||||
store.damage.glassToReplace = [
|
||||
{glassLocation: location1, glassName: name1},
|
||||
{glassLocation: location2, glassName: name2}
|
||||
{ glassLocation: location1, glassName: name1 },
|
||||
{ glassLocation: location2, glassName: name2 }
|
||||
],
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
|
|
@ -923,18 +897,16 @@ describe('Store', () => {
|
|||
await store.saveSession();
|
||||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
payload: expect.objectContaining({
|
||||
damage: expect.objectContaining({
|
||||
glassToReplace: expect.arrayContaining([
|
||||
{location: location1, name: name1},
|
||||
{location: location2, name: name2}
|
||||
])
|
||||
})
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
payload: expect.objectContaining({
|
||||
damage: expect.objectContaining({
|
||||
glassToReplace: expect.arrayContaining([
|
||||
{ location: location1, name: name1 },
|
||||
{ location: location2, name: name2 }
|
||||
])
|
||||
})
|
||||
})
|
||||
);
|
||||
}));
|
||||
});
|
||||
it('api call throws exception', async () => {
|
||||
expect.assertions(2);
|
||||
|
|
@ -947,12 +919,10 @@ describe('Store', () => {
|
|||
});
|
||||
|
||||
// Asserts
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining(
|
||||
{
|
||||
method: endpoints.SaveSession.method,
|
||||
endpoint: endpoints.SaveSession.url
|
||||
})
|
||||
);
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({
|
||||
method: endpoints.SaveSession.method,
|
||||
endpoint: endpoints.SaveSession.url
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1023,4 +993,17 @@ describe('Store', () => {
|
|||
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