@@ -132,7 +132,9 @@ export type GoalCalculatorConstantsMock = DeepPartial<
132132 GoalCalculatorConstantsQuery [ 'constant' ]
133133> ;
134134
135- export interface PdsGoalCalculatorTestWrapperProps {
135+ export interface PdsGoalCalculatorTestWrapperProps <
136+ TExtraMocks = Record < string , never > ,
137+ > {
136138 children ?: React . ReactNode ;
137139 withProvider ?: boolean ;
138140 calculationsMock ?: PdsGoalCalculationsMock ;
@@ -141,13 +143,25 @@ export interface PdsGoalCalculatorTestWrapperProps {
141143 userMock ?: GetUserMock ;
142144 constantsMock ?: GoalCalculatorConstantsMock ;
143145 supportRaisedMock ?: number ;
146+ /**
147+ * Extra GqlMockedProvider mocks merged on top of the defaults. Pass the
148+ * operation map as a generic argument so mock shapes are type-checked:
149+ * `<PdsGoalCalculatorTestWrapper<{ UpdatePdsGoalCalculation: UpdatePdsGoalCalculationMutation }> extraMocks={...} />`.
150+ * Each value may be a partial mock object or a resolver function (e.g. to
151+ * throw and exercise error paths).
152+ */
153+ extraMocks ?: {
154+ [ K in keyof TExtraMocks ] ?:
155+ | DeepPartial < TExtraMocks [ K ] >
156+ | ( ( ...args : never [ ] ) => unknown ) ;
157+ } ;
144158 onCall ?: MockLinkCallHandler ;
145159 router ?: React . ComponentProps < typeof TestRouter > [ 'router' ] ;
146160}
147161
148- export const PdsGoalCalculatorTestWrapper : React . FC <
149- PdsGoalCalculatorTestWrapperProps
150- > = ( {
162+ export const PdsGoalCalculatorTestWrapper = <
163+ TExtraMocks = Record < string , never > ,
164+ > ( {
151165 children,
152166 withProvider = true ,
153167 calculationsMock,
@@ -156,9 +170,10 @@ export const PdsGoalCalculatorTestWrapper: React.FC<
156170 userMock,
157171 constantsMock,
158172 supportRaisedMock,
173+ extraMocks,
159174 onCall,
160175 router,
161- } ) => {
176+ } : PdsGoalCalculatorTestWrapperProps < TExtraMocks > ) : React . ReactElement => {
162177 return (
163178 < ThemeProvider theme = { theme } >
164179 < TestRouter
@@ -176,95 +191,98 @@ export const PdsGoalCalculatorTestWrapper: React.FC<
176191 GetUser : GetUserQuery ;
177192 AccountListSupportRaised : AccountListSupportRaisedQuery ;
178193 } >
179- mocks = { {
180- PdsGoalCalculations : {
181- designationSupportCalculations : merge (
182- { } ,
183- calculationsDefault ,
184- calculationsMock ,
185- ) ,
186- } ,
187- PdsGoalCalculation : {
188- designationSupportCalculation : merge (
189- { } ,
190- calculationDefault ,
191- calculationMock ,
192- ) ,
193- } ,
194- HcmUser : {
195- hcm :
196- hcmUserMock === null
197- ? [ ]
198- : [ merge ( { } , hcmUserDefault . hcm [ 0 ] , hcmUserMock ) ] ,
199- } ,
200- ...( userMock ? { GetUser : userMock } : { } ) ,
201- ...( supportRaisedMock !== undefined
202- ? {
203- AccountListSupportRaised : {
204- accountList : {
205- id : 'account-list-1' ,
206- receivedPledges : supportRaisedMock ,
194+ mocks = { merge (
195+ {
196+ PdsGoalCalculations : {
197+ designationSupportCalculations : merge (
198+ { } ,
199+ calculationsDefault ,
200+ calculationsMock ,
201+ ) ,
202+ } ,
203+ PdsGoalCalculation : {
204+ designationSupportCalculation : merge (
205+ { } ,
206+ calculationDefault ,
207+ calculationMock ,
208+ ) ,
209+ } ,
210+ HcmUser : {
211+ hcm :
212+ hcmUserMock === null
213+ ? [ ]
214+ : [ merge ( { } , hcmUserDefault . hcm [ 0 ] , hcmUserMock ) ] ,
215+ } ,
216+ ...( userMock ? { GetUser : userMock } : { } ) ,
217+ ...( supportRaisedMock !== undefined
218+ ? {
219+ AccountListSupportRaised : {
220+ accountList : {
221+ id : 'account-list-1' ,
222+ receivedPledges : supportRaisedMock ,
223+ } ,
207224 } ,
225+ }
226+ : { } ) ,
227+ GoalCalculatorConstants : {
228+ constant : mergeWith (
229+ { } ,
230+ {
231+ mpdGoalBenefitsConstants : [ ] ,
232+ mpdGoalGeographicConstants : [
233+ {
234+ location : 'None' ,
235+ percentageMultiplier : 0 ,
236+ } ,
237+ {
238+ location : 'Orlando, FL' ,
239+ percentageMultiplier : 0.06 ,
240+ } ,
241+ {
242+ location : 'New York, NY' ,
243+ percentageMultiplier : 0.12 ,
244+ } ,
245+ ] ,
246+ mpdGoalMiscConstants : [
247+ {
248+ category :
249+ MpdGoalMiscConstantCategoryEnum . AdditionalRates ,
250+ label : MpdGoalMiscConstantLabelEnum . EmployerFicaRate ,
251+ fee : 0.08 ,
252+ } ,
253+ {
254+ category :
255+ MpdGoalMiscConstantCategoryEnum . AdditionalRates ,
256+ label :
257+ MpdGoalMiscConstantLabelEnum . PartTimeWorkCompensation ,
258+ fee : 0.17 ,
259+ } ,
260+ {
261+ category : MpdGoalMiscConstantCategoryEnum . Rates ,
262+ label : MpdGoalMiscConstantLabelEnum . AttritionRate ,
263+ fee : 0.06 ,
264+ } ,
265+ {
266+ category :
267+ MpdGoalMiscConstantCategoryEnum . AdditionalRates ,
268+ label : MpdGoalMiscConstantLabelEnum . CreditCardFeeRate ,
269+ fee : 0.06 ,
270+ } ,
271+ {
272+ category : MpdGoalMiscConstantCategoryEnum . Rates ,
273+ label : MpdGoalMiscConstantLabelEnum . AdminRate ,
274+ fee : 0.12 ,
275+ } ,
276+ ] ,
208277 } ,
209- }
210- : { } ) ,
211- GoalCalculatorConstants : {
212- constant : mergeWith (
213- { } ,
214- {
215- mpdGoalBenefitsConstants : [ ] ,
216- mpdGoalGeographicConstants : [
217- {
218- location : 'None' ,
219- percentageMultiplier : 0 ,
220- } ,
221- {
222- location : 'Orlando, FL' ,
223- percentageMultiplier : 0.06 ,
224- } ,
225- {
226- location : 'New York, NY' ,
227- percentageMultiplier : 0.12 ,
228- } ,
229- ] ,
230- mpdGoalMiscConstants : [
231- {
232- category :
233- MpdGoalMiscConstantCategoryEnum . AdditionalRates ,
234- label : MpdGoalMiscConstantLabelEnum . EmployerFicaRate ,
235- fee : 0.08 ,
236- } ,
237- {
238- category :
239- MpdGoalMiscConstantCategoryEnum . AdditionalRates ,
240- label :
241- MpdGoalMiscConstantLabelEnum . PartTimeWorkCompensation ,
242- fee : 0.17 ,
243- } ,
244- {
245- category : MpdGoalMiscConstantCategoryEnum . Rates ,
246- label : MpdGoalMiscConstantLabelEnum . AttritionRate ,
247- fee : 0.06 ,
248- } ,
249- {
250- category :
251- MpdGoalMiscConstantCategoryEnum . AdditionalRates ,
252- label : MpdGoalMiscConstantLabelEnum . CreditCardFeeRate ,
253- fee : 0.06 ,
254- } ,
255- {
256- category : MpdGoalMiscConstantCategoryEnum . Rates ,
257- label : MpdGoalMiscConstantLabelEnum . AdminRate ,
258- fee : 0.12 ,
259- } ,
260- ] ,
261- } ,
262- constantsMock ,
263- ( _objValue , srcValue ) =>
264- Array . isArray ( srcValue ) ? srcValue : undefined ,
265- ) ,
278+ constantsMock ,
279+ ( _objValue , srcValue ) =>
280+ Array . isArray ( srcValue ) ? srcValue : undefined ,
281+ ) ,
282+ } ,
266283 } ,
267- } }
284+ extraMocks ,
285+ ) }
268286 onCall = { onCall }
269287 >
270288 { withProvider ? (
0 commit comments