ISR-10442: Add unit tests for new helper
This commit is contained in:
parent
0cc245ca84
commit
d1af95bc15
1 changed files with 68 additions and 0 deletions
68
src/helpers/coverage-helper.spec.js
Normal file
68
src/helpers/coverage-helper.spec.js
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
import { updateClientSpecificFieldsForClaimRegistration } from '@/helpers/coverage-helper';
|
||||||
|
import parentAccountNumber from '@/constants/parent-account-numbers';
|
||||||
|
|
||||||
|
let mockStore;
|
||||||
|
|
||||||
|
jest.mock('@/store', () => ({
|
||||||
|
useMainStore: jest.fn(() => mockStore)
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('coverage-helper.js', () => {
|
||||||
|
describe('updateClientSpecificFieldsForClaimRegistration', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
mockStore = {
|
||||||
|
order: {
|
||||||
|
parentAccountNumber: null
|
||||||
|
},
|
||||||
|
isITAC: false
|
||||||
|
};
|
||||||
|
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Sets additionalInfo fields when parent account is USAA and isITAC is true', () => {
|
||||||
|
// Arrange
|
||||||
|
const payload = {};
|
||||||
|
mockStore.order.parentAccountNumber = parentAccountNumber.USAA;
|
||||||
|
mockStore.isITAC = true;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
updateClientSpecificFieldsForClaimRegistration(payload);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(payload.additionalInfo).toEqual({
|
||||||
|
offeredItac: 'true',
|
||||||
|
qualifiedForItac: 'true'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Sets additionalInfo fields when parent account is USAA and isITAC is false', () => {
|
||||||
|
// Arrange
|
||||||
|
const payload = {};
|
||||||
|
mockStore.order.parentAccountNumber = parentAccountNumber.USAA;
|
||||||
|
mockStore.isITAC = false;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
updateClientSpecificFieldsForClaimRegistration(payload);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(payload.additionalInfo).toEqual({
|
||||||
|
offeredItac: 'false',
|
||||||
|
qualifiedForItac: 'false'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Does not set additionalInfo when parent account is not USAA', () => {
|
||||||
|
// Arrange
|
||||||
|
const payload = {};
|
||||||
|
mockStore.order.parentAccountNumber = 123456;
|
||||||
|
mockStore.isITAC = true;
|
||||||
|
|
||||||
|
// Act
|
||||||
|
updateClientSpecificFieldsForClaimRegistration(payload);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(payload.additionalInfo).toBeUndefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue