unit test updates
This commit is contained in:
parent
70e2552f65
commit
bc7ceb0a88
2 changed files with 60 additions and 250 deletions
|
|
@ -529,7 +529,7 @@ export const useMainStore = defineStore({
|
|||
const manualGlassNamesArray = [];
|
||||
const glassInformation = this.order.damage.glassToReplace;
|
||||
glassInformation?.forEach((glassPiece) => {
|
||||
manualGlassNamesArray.push(glassPiece.glassLocation.toUpperCase());
|
||||
manualGlassNamesArray.push(glassPiece?.glassLocation?.toUpperCase());
|
||||
});
|
||||
if (this.order.customer.address.state === 'FL' && this.order.damage.isRepair) {
|
||||
manualGlassNamesArray.push(damageLocationsSelected.WINDSHIELD.toUpperCase());
|
||||
|
|
|
|||
|
|
@ -1725,48 +1725,26 @@ describe('Store', () => {
|
|||
});
|
||||
it('calls api with expected payload', () => {
|
||||
// Arrange
|
||||
const location = getRandomString(10, 15);
|
||||
const location = getRandomString(10, 15).toUpperCase();
|
||||
store.order.damage.glassToReplace = [
|
||||
{
|
||||
glassLocation: location
|
||||
}
|
||||
];
|
||||
const referralCorrelationId = getRandomGuid();
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
const accountNumber = getRandomString(6, 6);
|
||||
const additionalInfo = {
|
||||
schoolProperty: '',
|
||||
parkingLot: ''
|
||||
};
|
||||
const insured = {
|
||||
address: {
|
||||
state: getRandomString(2, 2)
|
||||
}
|
||||
};
|
||||
const lossInfo = {
|
||||
vehicle: {
|
||||
endorsements: []
|
||||
},
|
||||
manualGlassNames: [location]
|
||||
};
|
||||
const policy = {
|
||||
policyState: insured.address.state,
|
||||
status: getRandomString(6, 8),
|
||||
currentDeductible: getRandomInt(0, 5000),
|
||||
noCoverage: getRandomBoolean()
|
||||
};
|
||||
const orderItems = [
|
||||
{
|
||||
name: location.toUpperCase()
|
||||
}
|
||||
];
|
||||
const endorsements = [];
|
||||
const manualGlassNames = [location];
|
||||
const policyState = getRandomString(2, 2);
|
||||
const status = getRandomString(6, 8);
|
||||
const currentDeductible = getRandomInt(0, 5000);
|
||||
const noCoverage = getRandomBoolean();
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.order.referralNumber = referralNumber;
|
||||
store.issConfig.parentAccountNumber = accountNumber;
|
||||
store.order.currentDeductible = policy.currentDeductible;
|
||||
store.order.policy.noCoverage = policy.noCoverage;
|
||||
store.order.policy.status = policy.status;
|
||||
store.order.customer.address.state = policy.policyState;
|
||||
store.order.currentDeductible = currentDeductible;
|
||||
store.order.policy.noCoverage = noCoverage;
|
||||
store.order.policy.status = status;
|
||||
store.order.customer.address.state = policyState;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
|
|
@ -1778,54 +1756,31 @@ describe('Store', () => {
|
|||
endpoint: endpoints.FinalDeductible.url,
|
||||
payload: ({
|
||||
referralCorrelationId,
|
||||
referralNumber,
|
||||
accountNumber,
|
||||
additionalInfo: {
|
||||
schoolProperty: additionalInfo.schoolProperty,
|
||||
parkingLot: additionalInfo.parkingLot
|
||||
},
|
||||
insured: {
|
||||
address: {
|
||||
state: insured.address.state
|
||||
}
|
||||
},
|
||||
lossInfo: {
|
||||
vehicle: {
|
||||
endorsements: lossInfo.vehicle.endorsements
|
||||
},
|
||||
manualGlassNames: lossInfo.manualGlassNames
|
||||
},
|
||||
policy: {
|
||||
policyState: policy.policyState,
|
||||
status: policy.status,
|
||||
currentDeductible: policy.currentDeductible,
|
||||
noCoverage: policy.noCoverage
|
||||
},
|
||||
orderItems
|
||||
endorsements,
|
||||
manualGlassNames,
|
||||
policyState,
|
||||
status,
|
||||
currentDeductible,
|
||||
noCoverage
|
||||
})
|
||||
}));
|
||||
});
|
||||
it('only "Yes" endorsement answers are added to payload', () => {
|
||||
// Arrange
|
||||
store.order.damage.glassToReplace = [];
|
||||
const referralCorrelationId = getRandomGuid();
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
const accountNumber = getRandomString(6, 6);
|
||||
const additionalInfo = {
|
||||
schoolProperty: '',
|
||||
parkingLot: ''
|
||||
};
|
||||
const insured = {
|
||||
address: {
|
||||
state: getRandomString(2, 2)
|
||||
const location = getRandomString(10, 15).toUpperCase();
|
||||
store.order.damage.glassToReplace = [
|
||||
{
|
||||
glassLocation: location
|
||||
}
|
||||
};
|
||||
const lossInfo = {
|
||||
vehicle: {
|
||||
endorsements: []
|
||||
},
|
||||
manualGlassNames: []
|
||||
};
|
||||
];
|
||||
const referralCorrelationId = getRandomGuid();
|
||||
const accountNumber = getRandomString(6, 6);
|
||||
const manualGlassNames = [location];
|
||||
const policyState = getRandomString(2, 2);
|
||||
const status = getRandomString(6, 8);
|
||||
const currentDeductible = getRandomInt(0, 5000);
|
||||
const noCoverage = getRandomBoolean();
|
||||
const endorsementAnswers = [
|
||||
{
|
||||
questionNum: getRandomInt(1, 10),
|
||||
|
|
@ -1846,20 +1801,12 @@ describe('Store', () => {
|
|||
selectedAnswer: 'No'
|
||||
}
|
||||
];
|
||||
const policy = {
|
||||
policyState: insured.address.state,
|
||||
status: getRandomString(6, 8),
|
||||
currentDeductible: getRandomInt(0, 5000),
|
||||
noCoverage: getRandomBoolean()
|
||||
};
|
||||
const orderItems = [];
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.order.referralNumber = referralNumber;
|
||||
store.issConfig.parentAccountNumber = accountNumber;
|
||||
store.order.currentDeductible = policy.currentDeductible;
|
||||
store.order.policy.noCoverage = policy.noCoverage;
|
||||
store.order.policy.status = policy.status;
|
||||
store.order.customer.address.state = policy.policyState;
|
||||
store.order.currentDeductible = currentDeductible;
|
||||
store.order.policy.noCoverage = noCoverage;
|
||||
store.order.policy.status = status;
|
||||
store.order.customer.address.state = policyState;
|
||||
store.order.policy.endorsementQuestionAnswers = endorsementAnswers;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
|
|
@ -1873,161 +1820,41 @@ describe('Store', () => {
|
|||
endpoint: endpoints.FinalDeductible.url,
|
||||
payload: ({
|
||||
referralCorrelationId,
|
||||
referralNumber,
|
||||
accountNumber,
|
||||
additionalInfo: {
|
||||
schoolProperty: additionalInfo.schoolProperty,
|
||||
parkingLot: additionalInfo.parkingLot
|
||||
},
|
||||
insured: {
|
||||
address: {
|
||||
state: insured.address.state
|
||||
}
|
||||
},
|
||||
lossInfo: {
|
||||
vehicle: {
|
||||
endorsements: expected
|
||||
},
|
||||
manualGlassNames: lossInfo.manualGlassNames
|
||||
},
|
||||
policy: {
|
||||
policyState: policy.policyState,
|
||||
status: policy.status,
|
||||
currentDeductible: policy.currentDeductible,
|
||||
noCoverage: policy.noCoverage
|
||||
},
|
||||
orderItems
|
||||
endorsements: expected,
|
||||
manualGlassNames,
|
||||
policyState,
|
||||
status,
|
||||
currentDeductible,
|
||||
noCoverage
|
||||
})
|
||||
}));
|
||||
});
|
||||
it('additionalInfo is added to payload when both endorsements are present', () => {
|
||||
it('manualGlassNames updated if Florida windshield repair', () => {
|
||||
// Arrange
|
||||
store.order.damage.glassToReplace = [];
|
||||
const referralCorrelationId = getRandomGuid();
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
const accountNumber = getRandomString(6, 6);
|
||||
const additionalInfo = {
|
||||
schoolProperty: 'Yes',
|
||||
parkingLot: 'Yes'
|
||||
};
|
||||
const insured = {
|
||||
address: {
|
||||
state: getRandomString(2, 2)
|
||||
}
|
||||
};
|
||||
const lossInfo = {
|
||||
vehicle: {
|
||||
endorsements: ['Parking Guard', 'Educator']
|
||||
},
|
||||
manualGlassNames: []
|
||||
};
|
||||
const endorsementAnswers = [
|
||||
const location = 'WINDSHIELD';
|
||||
store.order.damage.glassToReplace = [
|
||||
{
|
||||
questionNum: getRandomInt(1, 10),
|
||||
endorsementName: 'Parking Guard',
|
||||
questionText: getRandomString(50, 100),
|
||||
selectedAnswer: 'Yes'
|
||||
},
|
||||
{
|
||||
questionNum: getRandomInt(1, 10),
|
||||
endorsementName: 'Educator',
|
||||
questionText: getRandomString(50, 100),
|
||||
selectedAnswer: 'Yes'
|
||||
glassLocation: location
|
||||
}
|
||||
];
|
||||
const policy = {
|
||||
policyState: insured.address.state,
|
||||
status: getRandomString(6, 8),
|
||||
currentDeductible: getRandomInt(0, 5000),
|
||||
noCoverage: getRandomBoolean()
|
||||
};
|
||||
const orderItems = [];
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.order.referralNumber = referralNumber;
|
||||
store.issConfig.parentAccountNumber = accountNumber;
|
||||
store.order.currentDeductible = policy.currentDeductible;
|
||||
store.order.policy.noCoverage = policy.noCoverage;
|
||||
store.order.policy.status = policy.status;
|
||||
store.order.customer.address.state = policy.policyState;
|
||||
store.order.policy.endorsementQuestionAnswers = endorsementAnswers;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
// Act
|
||||
store.getFinalDeductible();
|
||||
|
||||
// Assert
|
||||
const expected = [endorsementAnswers[0].endorsementName, endorsementAnswers[1].endorsementName];
|
||||
expect(globalMethods.callHttpClient).toHaveBeenCalledWith(({
|
||||
method: endpoints.FinalDeductible.method,
|
||||
endpoint: endpoints.FinalDeductible.url,
|
||||
payload: ({
|
||||
referralCorrelationId,
|
||||
referralNumber,
|
||||
accountNumber,
|
||||
additionalInfo: {
|
||||
schoolProperty: additionalInfo.schoolProperty,
|
||||
parkingLot: additionalInfo.parkingLot
|
||||
},
|
||||
insured: {
|
||||
address: {
|
||||
state: insured.address.state
|
||||
}
|
||||
},
|
||||
lossInfo: {
|
||||
vehicle: {
|
||||
endorsements: expected
|
||||
},
|
||||
manualGlassNames: lossInfo.manualGlassNames
|
||||
},
|
||||
policy: {
|
||||
policyState: policy.policyState,
|
||||
status: policy.status,
|
||||
currentDeductible: policy.currentDeductible,
|
||||
noCoverage: policy.noCoverage
|
||||
},
|
||||
orderItems
|
||||
})
|
||||
}));
|
||||
});
|
||||
it('manualGlassNames and orderItems updated if Florida windshield repair', () => {
|
||||
// Arrange
|
||||
store.order.policy.endorsementQuestionAnswers = [];
|
||||
const referralCorrelationId = getRandomGuid();
|
||||
const referralNumber = getRandomString(6, 6);
|
||||
const accountNumber = getRandomString(6, 6);
|
||||
const additionalInfo = {
|
||||
schoolProperty: '',
|
||||
parkingLot: ''
|
||||
};
|
||||
const insured = {
|
||||
address: {
|
||||
state: 'FL'
|
||||
}
|
||||
};
|
||||
const lossInfo = {
|
||||
vehicle: {
|
||||
endorsements: []
|
||||
},
|
||||
manualGlassNames: ['Windshield']
|
||||
};
|
||||
const policy = {
|
||||
policyState: insured.address.state,
|
||||
status: getRandomString(6, 8),
|
||||
currentDeductible: getRandomInt(0, 5000),
|
||||
noCoverage: getRandomBoolean()
|
||||
};
|
||||
const orderItems = [
|
||||
{
|
||||
name: 'WINDSHIELD'
|
||||
}
|
||||
];
|
||||
const endorsements = [];
|
||||
const expectedManualGlassName = ['WINDSHIELD'];
|
||||
const policyState = getRandomString(2, 2);
|
||||
const status = getRandomString(6, 8);
|
||||
const currentDeductible = getRandomInt(0, 5000);
|
||||
const noCoverage = getRandomBoolean();
|
||||
store.order.referralCorrelationId = referralCorrelationId;
|
||||
store.order.referralNumber = referralNumber;
|
||||
store.issConfig.parentAccountNumber = accountNumber;
|
||||
store.order.currentDeductible = policy.currentDeductible;
|
||||
store.order.policy.noCoverage = policy.noCoverage;
|
||||
store.order.policy.status = policy.status;
|
||||
store.order.customer.address.state = policy.policyState;
|
||||
store.order.currentDeductible = currentDeductible;
|
||||
store.order.policy.noCoverage = noCoverage;
|
||||
store.order.policy.status = status;
|
||||
store.order.customer.address.state = policyState;
|
||||
store.order.damage.isRepair = true;
|
||||
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({}));
|
||||
|
||||
|
|
@ -2040,30 +1867,13 @@ describe('Store', () => {
|
|||
endpoint: endpoints.FinalDeductible.url,
|
||||
payload: ({
|
||||
referralCorrelationId,
|
||||
referralNumber,
|
||||
accountNumber,
|
||||
additionalInfo: {
|
||||
schoolProperty: additionalInfo.schoolProperty,
|
||||
parkingLot: additionalInfo.parkingLot
|
||||
},
|
||||
insured: {
|
||||
address: {
|
||||
state: insured.address.state
|
||||
}
|
||||
},
|
||||
lossInfo: {
|
||||
vehicle: {
|
||||
endorsements: lossInfo.vehicle.endorsements
|
||||
},
|
||||
manualGlassNames: lossInfo.manualGlassNames
|
||||
},
|
||||
policy: {
|
||||
policyState: policy.policyState,
|
||||
status: policy.status,
|
||||
currentDeductible: policy.currentDeductible,
|
||||
noCoverage: policy.noCoverage
|
||||
},
|
||||
orderItems
|
||||
endorsements,
|
||||
manualGlassNames: expectedManualGlassName,
|
||||
policyState,
|
||||
status,
|
||||
currentDeductible,
|
||||
noCoverage
|
||||
})
|
||||
}));
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue