9
9
ForbiddenError ,
10
10
BadRequestError ,
11
11
} from "../error" ;
12
+ import { ok , created , noContent } from '../response'
12
13
import * as ContextFactory from "../../test/fixtures/ContextFactory" ;
13
14
import * as APIGatewayProxyEventFactory from "../../test/fixtures/APIGatewayProxyEventFactory" ;
14
15
@@ -23,6 +24,33 @@ describe(APIGatewayProxyHandler.name, () => {
23
24
event = APIGatewayProxyEventFactory . factory ( ) ;
24
25
} ) ;
25
26
27
+ it ( "handles HTTP 200 response correctly" , async ( ) => {
28
+ const fn = handler . wrapper ( ( ) => {
29
+ return ok ( { result : "HTTP 200" } )
30
+ } ) as Handler < APIGatewayProxyEvent , APIGatewayProxyResult > ;
31
+
32
+ const result = await fn ( event , context , ( ) => { } ) ;
33
+ expect ( result ) . toMatchSnapshot ( ) ;
34
+ } ) ;
35
+
36
+ it ( "handles HTTP 201 response correctly" , async ( ) => {
37
+ const fn = handler . wrapper ( ( ) => {
38
+ return created ( { result : "HTTP 201" } )
39
+ } ) as Handler < APIGatewayProxyEvent , APIGatewayProxyResult > ;
40
+
41
+ const result = await fn ( event , context , ( ) => { } ) ;
42
+ expect ( result ) . toMatchSnapshot ( ) ;
43
+ } ) ;
44
+
45
+ it ( "handles HTTP 204 response correctly" , async ( ) => {
46
+ const fn = handler . wrapper ( ( ) => {
47
+ return noContent ( )
48
+ } ) as Handler < APIGatewayProxyEvent , APIGatewayProxyResult > ;
49
+
50
+ const result = await fn ( event , context , ( ) => { } ) ;
51
+ expect ( result ) . toMatchSnapshot ( ) ;
52
+ } ) ;
53
+
26
54
it ( "handles BadRequestError response correctly" , async ( ) => {
27
55
const fn = handler . wrapper ( ( ) => {
28
56
throw new BadRequestError ( "BadRequestError message" ) ;
0 commit comments