From 383d93e561e58a3495ee32aecfc0bc80b41b07bb Mon Sep 17 00:00:00 2001 From: Katie Kroell Date: Thu, 25 Jan 2024 15:07:21 -0500 Subject: [PATCH] remaining unit tests --- .../tpa-confirmation/tpa-confirmation.spec.js | 194 ++++++++++++++++++ 1 file changed, 194 insertions(+) diff --git a/src/layouts/tpa-confirmation/tpa-confirmation.spec.js b/src/layouts/tpa-confirmation/tpa-confirmation.spec.js index 258dc420..409efa9f 100644 --- a/src/layouts/tpa-confirmation/tpa-confirmation.spec.js +++ b/src/layouts/tpa-confirmation/tpa-confirmation.spec.js @@ -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', () => { + + }); + }); });