File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ const { serverless } = require ( '../' )
2
+
3
+ describe ( 'serverless-lambda' , ( ) => {
4
+ let spy , handler , context
5
+
6
+ beforeEach ( ( ) => {
7
+ context = { done : jest . fn ( ) }
8
+ spy = jest . fn ( )
9
+ handler = serverless ( async app => {
10
+ app . auth = ( ) => Promise . resolve ( { } )
11
+ app . on ( 'issues' , spy )
12
+ } )
13
+ } )
14
+
15
+ it ( 'responds with the homepage' , async ( ) => {
16
+ const event = { httpMethod : 'GET' , path : '/probot' }
17
+ await handler ( event , context )
18
+ expect ( context . done ) . toHaveBeenCalled ( )
19
+ expect ( context . done . mock . calls [ 0 ] [ 0 ] ) . toMatchSnapshot ( )
20
+ } )
21
+
22
+ it ( 'calls the event handler' , async ( ) => {
23
+ const event = {
24
+ body : {
25
+ installation : { id : 1 }
26
+ } ,
27
+ headers : {
28
+ 'x-github-event' : 'issues' ,
29
+ 'x-github-delivery' : 123
30
+ }
31
+ }
32
+
33
+ await handler ( event , context )
34
+ expect ( context . done ) . toHaveBeenCalled ( )
35
+ expect ( spy ) . toHaveBeenCalled ( )
36
+ } )
37
+ } )
You can’t perform that action at this time.
0 commit comments