remaining unit tests

This commit is contained in:
Katie Kroell 2024-01-25 15:07:21 -05:00
parent 86dc82070a
commit 383d93e561

View file

@ -10,6 +10,9 @@ import settleAllPromises from '@/helpers/layout-helper.js';
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { mount } from '@vue/test-utils';
import { createTestingPinia } from '@pinia/testing';
import userEvent from '@testing-library/user-event';
import bailoutMessage from '@/constants/bailoutMessage';
import { render } from '@testing-library/vue';
jest.mock('@/helpers/layout-helper.js', () => jest.fn());
@ -165,4 +168,195 @@ describe('TPAConfirmation.vue', () => {
expect(siteFooter.exists()).toBe(true);
});
});
describe('Computed properties', () => {
describe('Deductible Box value', () => {
test('Should return "Verifying coverage" when isVerified false', () => {
// Arrange
const initialStore = {
order: {
payment: {
insuranceCoverage: { isVerified: false }
}
}
};
const { wrapper } = getMountedComponent(initialStore);
const expected = 'Verifying coverage';
// Assert
expect(wrapper.vm.deductibleBoxValue).toBe(expected);
});
test('Should return deductible value when isVerified true', () => {
// Arrange
const currentDeductible = '500';
const initialStore = {
order: {
payment: {
insuranceCoverage: { isVerified: true }
},
currentDeductible
}
};
const { wrapper } = getMountedComponent(initialStore);
const notExpected = 'Verifying coverage';
// Assert
expect(wrapper.vm.deductibleBoxValue).not.toBe(notExpected);
});
});
});
describe('Methods', () => {
describe('getCustomValueFromString', () => {
describe('with argument deductibleAboveZero', () => {
test.each([
[false],
[true]
])(
'returns false when isVerified %p and currentDeductible is zero',
(isVerified) => {
// Arrange
const initialStore = {
order: {
payment: {
insuranceCoverage: { isVerified }
},
currentDeductible: 0
}
};
const { wrapper } = getMountedComponent(initialStore);
const argument = 'deductibleAboveZero';
// Act
const result = wrapper.vm.getCustomValueFromString(argument);
// Assert
expect(result).toBe(false);
}
);
test.each([
[true, true],
[false, false]
])(
'returns %p when isVerified %p and currentDeductible is not zero',
(expected, isVerified) => {
// Arrange
const initialStore = {
order: {
payment: {
insuranceCoverage: { isVerified }
},
currentDeductible: 500
}
};
const { wrapper } = getMountedComponent(initialStore);
const argument = 'deductibleAboveZero';
// Act
const result = wrapper.vm.getCustomValueFromString(argument);
// Assert
expect(result).toBe(expected);
}
);
});
describe('with argument zeroDeductible', () => {
test.each([
[true, true],
[false, false]
])(
'returns %p when isVerified is %p currentDeductible is zero',
(expected, isVerified) => {
// Arrange
const initialStore = {
order: {
payment: {
insuranceCoverage: { isVerified }
},
currentDeductible: 0
}
};
const { wrapper } = getMountedComponent(initialStore);
const argument = 'zeroDeductible';
// Act
const result = wrapper.vm.getCustomValueFromString(argument);
// Assert
expect(result).toBe(expected);
}
);
test.each([
[false],
[true]
])(
'returns false when isVerified is %p currentDeductible is not zero',
(isVerified) => {
// Arrange
const initialStore = {
order: {
payment: {
insuranceCoverage: { isVerified }
},
currentDeductible: 250
}
};
const { wrapper } = getMountedComponent(initialStore);
const argument = 'zeroDeductible';
// Act
const result = wrapper.vm.getCustomValueFromString(argument);
// Assert
expect(result).toBe(false);
}
);
});
describe('with argument verifyingCoverage', () => {
test.each([
[true, false],
[false, true]
])(
'with argument verifyingCoverage returns %p when isVerified %p',
(expected, isVerified) => {
// Arrange
const initialStore = {
order: {
payment: {
insuranceCoverage: { isVerified }
},
currentDeductible: 26
}
};
const { wrapper } = getMountedComponent(initialStore);
const argument = 'verifyingCoverage';
// Act
const result = wrapper.vm.getCustomValueFromString(argument);
// Assert
expect(result).toBe(expected);
}
);
});
});
describe('setBailoutInfo', () => {
test('setBailout method is called when routerLink clicked', async () => {
// Arrange
const { wrapper } = getMountedComponent({});
const contactCarrierText = wrapper.get('#contactCarrierText');
// Act
await contactCarrierText.trigger('click');
// Assert
expect(wrapper.vm.mainStore.setBailout).toHaveBeenCalledWith(
wrapper.vm.$router.currentRoute,
bailoutMessage.RequestCallback
);
});
});
// TODO: Add tests for forward navigation to carrier URL
describe('Navigation', () => {
});
});
});