From b23ad667a42da03cb40fa863a3a7b8879b9f583a Mon Sep 17 00:00:00 2001 From: Jason Lin Date: Wed, 8 May 2024 10:01:03 -0400 Subject: [PATCH] Add a test --- .../RateDetails/V2/rateDetailsHelpers.test.ts | 97 ++++++++++++++++++- .../RateDetails/V2/rateDetailsHelpers.ts | 3 +- 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/services/app-web/src/pages/StateSubmission/RateDetails/V2/rateDetailsHelpers.test.ts b/services/app-web/src/pages/StateSubmission/RateDetails/V2/rateDetailsHelpers.test.ts index 6d22db2f64..df707479bb 100644 --- a/services/app-web/src/pages/StateSubmission/RateDetails/V2/rateDetailsHelpers.test.ts +++ b/services/app-web/src/pages/StateSubmission/RateDetails/V2/rateDetailsHelpers.test.ts @@ -1,5 +1,6 @@ import { FormikRateForm } from "./RateDetailsV2" -import { convertGQLRateToRateForm, generateUpdatedRates } from "./rateDetailsHelpers" +import { convertGQLRateToRateForm, generateUpdatedRates, isRatePartiallyFilled, convertRateFormToGQLRateFormData } from "./rateDetailsHelpers" +import {RateFormData} from '../../../../gen/gqlClient'; describe('generateUpdatedRates', () => { const emptyRateForm = () => convertGQLRateToRateForm(jest.fn()) @@ -67,5 +68,99 @@ describe('generateUpdatedRates', () => { }) } ) +}) + +describe('isRatePartiallyFilled', () => { + const testCases = [ + { + testValue: { + rateDocuments: [], + supportingDocuments: [], + rateProgramIDs: [], + certifyingActuaryContacts: [], + addtlActuaryContacts: [] + }, + testName: 'empty rate', + expectedResult: false, + }, + { + testValue: { + rateDocuments: [], + supportingDocuments: [], + rateProgramIDs: [], + certifyingActuaryContacts: [ + { + name: '', + titleRole: '', + email: '', + actuarialFirm: undefined, + actuarialFirmOther: '', + } + ], + addtlActuaryContacts: [] + } , + testName: 'there is a certifying actuary with empty values', + expectedResult: false, + }, + { + testValue: { + rateDocuments: [], + supportingDocuments: [], + rateProgramIDs: [], + certifyingActuaryContacts: [ + { + name: 'Bob' + } + ], + addtlActuaryContacts: [] + }, + testName: 'there is a certifying actuary', + expectedResult: true, + }, + { + testValue: { + rateDocuments: [], + supportingDocuments: [], + rateProgramIDs: [], + certifyingActuaryContacts: [], + addtlActuaryContacts: [ + { + actuarialFirm: 'OTHER' + } + ] + }, + testName: 'there is an additional actuary', + expectedResult: true, + }, + { + testValue: { + rateDocuments: [], + supportingDocuments: [], + rateProgramIDs: [], + certifyingActuaryContacts: [], + addtlActuaryContacts: [], + rateType: 'NEW' + }, + testName: 'rate type is filled in', + expectedResult: true, + }, + { + testValue: { + rateDocuments: [], + supportingDocuments: [], + rateProgramIDs: ['test-program'], + certifyingActuaryContacts: [], + addtlActuaryContacts: [], + }, + testName: 'rate programs is filled in', + expectedResult: true, + }, + ] + test.each(testCases)( + 'Returns correct boolean: $testName', + ({ testValue, expectedResult }) => { + expect(isRatePartiallyFilled(testValue as unknown as RateFormData)).toEqual(expectedResult) + } + ) }) diff --git a/services/app-web/src/pages/StateSubmission/RateDetails/V2/rateDetailsHelpers.ts b/services/app-web/src/pages/StateSubmission/RateDetails/V2/rateDetailsHelpers.ts index 02ad577d19..2823bce3ae 100644 --- a/services/app-web/src/pages/StateSubmission/RateDetails/V2/rateDetailsHelpers.ts +++ b/services/app-web/src/pages/StateSubmission/RateDetails/V2/rateDetailsHelpers.ts @@ -133,5 +133,6 @@ const convertGQLRateToRateForm = (getKey: S3ClientT['getKey'], rate?: Rate, pare export { convertGQLRateToRateForm, convertRateFormToGQLRateFormData, - generateUpdatedRates + generateUpdatedRates, + isRatePartiallyFilled }