File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
lambdas/example-lambda/src Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 1- // Replace me with the actual tests for your Lambda function
1+ import { handler } from '../index' ;
2+
3+ describe ( 'event-logging Lambda' , ( ) => {
4+ let logSpy : jest . SpyInstance ;
5+
6+ beforeAll ( ( ) => {
7+ logSpy = jest . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
8+ } ) ;
9+
10+ afterEach ( ( ) => {
11+ logSpy . mockClear ( ) ;
12+ } ) ;
13+
14+ afterAll ( ( ) => {
15+ logSpy . mockRestore ( ) ;
16+ } ) ;
17+
18+ it ( 'logs the input event and returns 200' , async ( ) => {
19+ const event = { foo : 'bar' } ;
20+ const result = await handler ( event , { } as any , ( ) => undefined ) ;
21+
22+ expect ( logSpy ) . toHaveBeenCalledWith ( 'Received event:' , event ) ;
23+ expect ( result ) . toEqual ( {
24+ statusCode : 200 ,
25+ body : 'Event logged' ,
26+ } ) ;
27+ } ) ;
28+ } ) ;
You can’t perform that action at this time.
0 commit comments