@@ -36,17 +36,6 @@ describe("test", () => {
3636 await plugin . hooks [ "offline-sns:start:end" ] ( ) ;
3737 } ) ;
3838
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-
5039 it ( 'should send event to topic ARN' , async ( ) => {
5140 plugin = new ServerlessOfflineSns ( createServerless ( accountId ) ) ;
5241 const snsAdapter = await plugin . start ( ) ;
@@ -237,11 +226,20 @@ describe("test", () => {
237226 await new Promise ( ( res ) => setTimeout ( res , 100 ) ) ;
238227 expect ( state . getPongs ( ) ) . to . eq ( 1 ) ;
239228 } ) ;
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+ } ) ;
240240
241241 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" ) ) ;
245243 const snsAdapter = await plugin . start ( ) ;
246244 await snsAdapter . publish (
247245 `arn:aws:sns:us-east-1:${ accountId } :test-topic-async` ,
@@ -547,51 +545,6 @@ const createServerless = (
547545 } ;
548546} ;
549547
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-
595548const createServerlessMultiDot = (
596549 accountId : number ,
597550 handlerName : string = "pongHandler" ,
0 commit comments