11import { PublishCommand } from '@aws-sdk/client-sns'
2+ import { FormStatus } from '@defra/forms-model'
23
34import { publishFormAdapterEvent } from '~/src/server/messaging/formAdapterEventPublisher.js'
45import { getSNSClient } from '~/src/server/messaging/sns.js'
@@ -33,7 +34,7 @@ const basePayload = {
3334 formSlug : 'test-form' ,
3435 formName : 'Test Form' ,
3536 referenceNumber : 'REF-123456' ,
36- status : 'live' ,
37+ status : FormStatus . Live ,
3738 isPreview : false ,
3839 notificationEmail : 'test@example.com'
3940 } ,
@@ -54,7 +55,7 @@ describe('formAdapterEventPublisher', () => {
5455 /** @type {FormAdapterSubmissionMessagePayload } */
5556 let mockPayload
5657
57- /** @type {any } */
58+ /** @type {{ send: jest.Mock } } */
5859 let mockSnsClient
5960
6061 beforeEach ( ( ) => {
@@ -65,10 +66,14 @@ describe('formAdapterEventPublisher', () => {
6566 meta : { ...basePayload . meta }
6667 } )
6768
68- mockSnsClient = {
69- send : jest . fn ( )
70- }
71- jest . mocked ( getSNSClient ) . mockReturnValue ( mockSnsClient )
69+ mockSnsClient = { send : jest . fn ( ) }
70+ jest
71+ . mocked ( getSNSClient )
72+ . mockReturnValue (
73+ /** @type {import('@aws-sdk/client-sns').SNSClient } */ (
74+ /** @type {unknown } */ ( mockSnsClient )
75+ )
76+ )
7277 } )
7378
7479 describe ( 'publishFormAdapterEvent' , ( ) => {
@@ -123,7 +128,7 @@ describe('formAdapterEventPublisher', () => {
123128 formSlug : 'complex-form' ,
124129 formName : 'Complex Form' ,
125130 referenceNumber : 'COMPLEX-REF' ,
126- status : 'live' ,
131+ status : FormStatus . Live ,
127132 isPreview : false ,
128133 notificationEmail : 'complex@example.com'
129134 } ,
@@ -263,12 +268,18 @@ describe('per-form topic routing (SNS_FORM_TOPIC_ARN_MAP)', () => {
263268 meta : { ...basePayload . meta , formId : mappedFormId }
264269 }
265270
266- /** @type {any } */
271+ /** @type {{ send: jest.Mock } } */
267272 let mockSnsClient
268273
269274 beforeEach ( ( ) => {
270275 mockSnsClient = { send : jest . fn ( ) }
271- jest . mocked ( getSNSClient ) . mockReturnValue ( mockSnsClient )
276+ jest
277+ . mocked ( getSNSClient )
278+ . mockReturnValue (
279+ /** @type {import('@aws-sdk/client-sns').SNSClient } */ (
280+ /** @type {unknown } */ ( mockSnsClient )
281+ )
282+ )
272283 } )
273284
274285 it ( 'publishes to form-specific topic in addition to global topic when formId is mapped' , async ( ) => {
0 commit comments