Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLin0991 committed May 8, 2024
1 parent 1cd95cf commit b23ad66
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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())
Expand Down Expand Up @@ -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)
}
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,6 @@ const convertGQLRateToRateForm = (getKey: S3ClientT['getKey'], rate?: Rate, pare
export {
convertGQLRateToRateForm,
convertRateFormToGQLRateFormData,
generateUpdatedRates
generateUpdatedRates,
isRatePartiallyFilled
}

0 comments on commit b23ad66

Please sign in to comment.