@@ -36,17 +36,6 @@ describe("test", () => {
36
36
await plugin . hooks [ "offline-sns:start:end" ] ( ) ;
37
37
} ) ;
38
38
39
- it ( 'should send event to topic ARN' , async ( ) => {
40
- plugin = new ServerlessOfflineSns ( createServerless ( accountId ) ) ;
41
- const snsAdapter = await plugin . start ( ) ;
42
- await snsAdapter . publish (
43
- `arn:aws:sns:us-east-1:${ accountId } :test-topic` ,
44
- "{}"
45
- ) ;
46
- await new Promise ( ( res ) => setTimeout ( res , 500 ) ) ;
47
- expect ( state . getPongs ( ) ) . to . eq ( 2 ) ;
48
- } ) ;
49
-
50
39
it ( 'should send event to topic ARN' , async ( ) => {
51
40
plugin = new ServerlessOfflineSns ( createServerless ( accountId ) ) ;
52
41
const snsAdapter = await plugin . start ( ) ;
@@ -237,11 +226,20 @@ describe("test", () => {
237
226
await new Promise ( ( res ) => setTimeout ( res , 100 ) ) ;
238
227
expect ( state . getPongs ( ) ) . to . eq ( 1 ) ;
239
228
} ) ;
229
+
230
+ it ( 'should support commonjs/default handlers' , async ( ) => {
231
+ plugin = new ServerlessOfflineSns ( createServerless ( accountId , "defaultExportHandler" ) ) ;
232
+ const snsAdapter = await plugin . start ( ) ;
233
+ await snsAdapter . publish (
234
+ `arn:aws:sns:us-east-1:${ accountId } :test-topic` ,
235
+ "{}"
236
+ ) ;
237
+ await new Promise ( ( res ) => setTimeout ( res , 100 ) ) ;
238
+ expect ( state . getPongs ( ) ) . to . eq ( 2 ) ;
239
+ } ) ;
240
240
241
241
it ( 'should support async handlers with no callback' , async ( ) => {
242
- plugin = new ServerlessOfflineSns ( createServerless ( accountId , "asyncHandler" ) , {
243
- skipCacheInvalidation : true ,
244
- } ) ;
242
+ plugin = new ServerlessOfflineSns ( createServerless ( accountId , "asyncHandler" ) ) ;
245
243
const snsAdapter = await plugin . start ( ) ;
246
244
await snsAdapter . publish (
247
245
`arn:aws:sns:us-east-1:${ accountId } :test-topic-async` ,
@@ -547,51 +545,6 @@ const createServerless = (
547
545
} ;
548
546
} ;
549
547
550
- const createServerlessCacheInvalidation = (
551
- accountId : number ,
552
- handlerName : string = "pongHandler" ,
553
- host = null
554
- ) => {
555
- return {
556
- config : { } ,
557
- service : {
558
- custom : {
559
- "serverless-offline-sns" : {
560
- debug : true ,
561
- port : 4002 ,
562
- accountId,
563
- host,
564
- invalidateCache : true ,
565
- } ,
566
- } ,
567
- provider : {
568
- region : "us-east-1" ,
569
- environment : {
570
- MY_VAR : "MY_VAL" ,
571
- } ,
572
- } ,
573
- functions : {
574
- pong : {
575
- handler : "test/mock/handler." + handlerName ,
576
- events : [
577
- {
578
- sns : `arn:aws:sns:us-west-2:${ accountId } :test-topic` ,
579
- } ,
580
- ] ,
581
- } ,
582
- } ,
583
- resources : { } ,
584
- } ,
585
- cli : {
586
- log : ( data ) => {
587
- if ( process . env . DEBUG ) {
588
- console . log ( data ) ;
589
- }
590
- } ,
591
- } ,
592
- } ;
593
- } ;
594
-
595
548
const createServerlessMultiDot = (
596
549
accountId : number ,
597
550
handlerName : string = "pongHandler" ,
0 commit comments