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