SSR-706 Add Unit Tests for field changes

This commit is contained in:
Josh Dassinger 2023-10-05 08:21:24 -05:00
parent 3b4f120943
commit 0bef00dfa7
2 changed files with 7 additions and 2 deletions

View file

@ -469,6 +469,7 @@ export const useMainStore = defineStore({
}, (error) => {
this.order.payment.insuranceCoverage.isVerified = false;
this.order.payment.insuranceCoverage.coverageStatus = coverageStatuses.PENDING;
this.order.payment.insuranceCoverage.claimNumber = null;
return reject(error);
});
});

View file

@ -396,6 +396,7 @@ describe('Store', () => {
expect(globalMethods.callHttpClient).toHaveBeenCalled();
expect(store.payment.insuranceCoverage.isVerified).toBe(true);
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.NO_COMP);
expect(store.payment.insuranceCoverage.claimNumber).toBe(null);
});
it('successful response with coverage => isVerified true and coverage status verified', async () => {
@ -422,11 +423,12 @@ describe('Store', () => {
expect(globalMethods.callHttpClient).toHaveBeenCalled();
expect(store.payment.insuranceCoverage.isVerified).toBe(true);
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.VERIFIED);
expect(store.payment.insuranceCoverage.claimNumber).toBe(response.data.claimNumber);
});
it('Call to client returns exception, resulting in object with error property being returned', async () => {
// Arrange
expect.assertions(4);
expect.assertions(5);
const error = 'this is the error';
globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.reject(error));
@ -439,6 +441,7 @@ describe('Store', () => {
expect(globalMethods.callHttpClient).toHaveBeenCalled();
expect(store.payment.insuranceCoverage.isVerified).toBe(false);
expect(store.payment.insuranceCoverage.coverageStatus).toBe(coverageStatuses.PENDING);
expect(store.payment.insuranceCoverage.claimNumber).toBe(null);
});
});
@ -645,7 +648,8 @@ describe('Store', () => {
policyFirstName: customer.firstName,
policyLastName: customer.lastName,
policyPhoneNumber: customer.phoneNumber,
policyEmail: customer.emailAddress
policyEmail: customer.emailAddress,
policyState: customer.address.state
}),
policyNumber: policy.policyNumber,
policyZipCode: policy.policyZipCode,