@@ -356,12 +356,15 @@ describe('SummaryPageController - Payment (DF-832)', () => {
356356 } as FormSubmissionState )
357357
358358 const outputSubmit = jest . fn ( )
359+ const formSubmissionSubmit = jest . fn ( )
359360
360361 model . services = {
361362 ...model . services ,
362363 formSubmissionService : {
363364 ...model . services . formSubmissionService ,
364- submit : jest . fn ( ) . mockResolvedValue ( { data : { reference : 'r' } } )
365+ submit : formSubmissionSubmit . mockResolvedValue ( {
366+ data : { reference : 'r' }
367+ } )
365368 } ,
366369 outputService : {
367370 ...model . services . outputService ,
@@ -387,7 +390,14 @@ describe('SummaryPageController - Payment (DF-832)', () => {
387390 contact : { online : { url : '/help' } }
388391 } as unknown as Parameters < typeof submitForm > [ 1 ]
389392
390- return { request, context, viewModel, formMetadata, outputSubmit }
393+ return {
394+ request,
395+ context,
396+ viewModel,
397+ formMetadata,
398+ outputSubmit,
399+ formSubmissionSubmit
400+ }
391401 }
392402
393403 it ( 're-throws as PaymentSubmissionError when outputService fails and a payment has been captured' , async ( ) => {
@@ -428,5 +438,53 @@ describe('SummaryPageController - Payment (DF-832)', () => {
428438 )
429439 ) . rejects . toBe ( err )
430440 } )
441+
442+ it ( 'submits with correct payload' , async ( ) => {
443+ const {
444+ request,
445+ context,
446+ viewModel,
447+ formMetadata,
448+ formSubmissionSubmit
449+ } = buildSubmitHarness ( { captured : true } )
450+
451+ await submitForm (
452+ context ,
453+ formMetadata ,
454+ request ,
455+ viewModel ,
456+ model ,
457+ 'notify@example.com'
458+ )
459+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
460+ const paymentCall = formSubmissionSubmit . mock . calls [ 0 ] [ 0 ]
461+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
462+ const paymentItems = paymentCall . main as unknown as {
463+ name : string
464+ title : string
465+ value : string
466+ } [ ]
467+ expect ( paymentItems ) . toHaveLength ( 4 )
468+ expect ( paymentItems [ 0 ] ) . toEqual ( {
469+ name : 'paymentField_paymentDescription' ,
470+ title : 'Payment description' ,
471+ value : 'Test payment'
472+ } )
473+ expect ( paymentItems [ 1 ] ) . toEqual ( {
474+ name : 'paymentField_paymentAmount' ,
475+ title : 'Payment amount' ,
476+ value : '£99.00'
477+ } )
478+ expect ( paymentItems [ 2 ] ) . toEqual ( {
479+ name : 'paymentField_paymentReference' ,
480+ title : 'Payment reference' ,
481+ value : 'ref-1'
482+ } )
483+ expect ( paymentItems [ 3 ] ) . toEqual ( {
484+ name : 'paymentField_paymentDate' ,
485+ title : 'Payment date' ,
486+ value : ''
487+ } )
488+ } )
431489 } )
432490} )
0 commit comments