11import _ from 'underscore' ;
22import {
3- apiGatewayRequest ,
43 handlerContext ,
54 albRequest ,
65 albMultiValHeadersRequest ,
76 apiGatewayRequestRawQuery ,
7+ makeAPIGatewayRequestEvent ,
88} from './samples' ;
99import { spy , SinonSpy , assert } from 'sinon' ;
1010import { Application , Request , Response , Router } from '../src' ;
@@ -22,7 +22,7 @@ describe('integration tests', () => {
2222 } ) ;
2323
2424 const makeRequestEvent = ( path : string , base ?: RequestEvent , method ?: string ) : RequestEvent => {
25- return _ . extend ( base || apiGatewayRequest ( ) , { path : path , httpMethod : ( method || 'GET' ) } ) ;
25+ return _ . extend ( base , { path : path , httpMethod : ( method || 'GET' ) } ) ;
2626 } ;
2727
2828 const testWithLastResortHandler = ( code : number , desc : string , testHeaders : string [ ] = [ ] , expectedBody = '' ) : void => {
@@ -54,7 +54,7 @@ describe('integration tests', () => {
5454
5555 const testOutcome = ( method : string , path : string , expectedBody : string ) : void => {
5656 const cb = spy ( ) ,
57- evt = makeRequestEvent ( path , apiGatewayRequest ( ) , method ) ;
57+ evt = makeAPIGatewayRequestEvent ( { path, httpMethod : method } ) ;
5858
5959 app . run ( evt , handlerContext ( ) , cb ) ;
6060
@@ -121,7 +121,7 @@ describe('integration tests', () => {
121121 } ;
122122
123123 it ( 'works - APIGW' , ( ) => {
124- const cb = test ( makeRequestEvent ( '/hello/world' ) ) ;
124+ const cb = test ( makeAPIGatewayRequestEvent ( { path : '/hello/world' } ) ) ;
125125
126126 assert . calledWithExactly ( cb , undefined , {
127127 statusCode : 200 ,
@@ -342,7 +342,10 @@ describe('integration tests', () => {
342342 // eslint-disable-next-line max-len,max-params
343343 const addTestsForMethod = ( method : string , code : number , desc : string , hdrName : string , hdrVal : string , expectedBody : string , prep : ( ) => void , contentType ?: string ) : void => {
344344 const baseEvents = {
345- 'APIGW' : apiGatewayRequest ( ) ,
345+ 'APIGW' : makeAPIGatewayRequestEvent ( {
346+ path : '/hello/world' ,
347+ httpMethod : method ,
348+ } ) ,
346349 'ALB' : albRequest ( ) ,
347350 'ALBMV' : albMultiValHeadersRequest ( ) ,
348351 } ;
@@ -760,7 +763,7 @@ describe('integration tests', () => {
760763 describe ( 'request object' , ( ) => {
761764
762765 it ( 'has an immutable context property' , ( ) => {
763- let evt = makeRequestEvent ( '/test' , apiGatewayRequest ( ) , 'GET' ) ,
766+ let evt = makeAPIGatewayRequestEvent ( { path : '/test' , httpMethod : 'GET' } ) ,
764767 ctx = handlerContext ( true ) ,
765768 handler ;
766769
0 commit comments