1
- import _ from 'underscore' ;
2
1
import { Application , Request , Response } from '../../src' ;
3
- import { apiGatewayRequest , handlerContext } from '../samples' ;
2
+ import { handlerContext , makeAPIGatewayRequestEvent } from '../samples' ;
4
3
import { expect } from 'chai' ;
5
4
import { RouteMatchingProcessorChain } from '../../src/chains/RouteMatchingProcessorChain' ;
6
5
import { PathParams } from '../../src/interfaces' ;
@@ -22,7 +21,7 @@ describe('RouteMatchingProcessorChain', () => {
22
21
describe ( 'matches' , ( ) => {
23
22
const test = ( method : string | undefined , routes : PathParams , path : string , expectation : boolean , caseSensitive = false ) : void => {
24
23
let app = new Application ( ) ,
25
- req = new Request ( app , _ . extend ( apiGatewayRequest ( ) , { path : path } ) , handlerContext ( ) ) ,
24
+ req = new Request ( app , makeAPIGatewayRequestEvent ( { path : path } ) , handlerContext ( ) ) ,
26
25
chain = new RouteMatchingProcessorChain ( [ ] , routes , method , caseSensitive ) ;
27
26
28
27
expect ( chain . matches ( req ) ) . to . eql ( expectation ) ;
@@ -138,7 +137,7 @@ describe('RouteMatchingProcessorChain', () => {
138
137
describe ( 'makeSubRequest' , ( ) => {
139
138
const test = ( routes : PathParams , path : string , expectation : StringMap ) : void => {
140
139
let app = new Application ( ) ,
141
- req = new Request ( app , _ . extend ( apiGatewayRequest ( ) , { path : path } ) , handlerContext ( ) ) ,
140
+ req = new Request ( app , makeAPIGatewayRequestEvent ( { path : path } ) , handlerContext ( ) ) ,
142
141
chain = new TestRouteMatchingProcessorChain ( [ ] , routes ) ,
143
142
subReq = chain . _makeSubRequest ( req ) ;
144
143
@@ -154,7 +153,7 @@ describe('RouteMatchingProcessorChain', () => {
154
153
// sending this character using UTF-8 encoding (i.e. %C3%AA)
155
154
const path = '/hello/%EA' ,
156
155
app = new Application ( ) ,
157
- req = new Request ( app , _ . extend ( apiGatewayRequest ( ) , { path } ) , handlerContext ( ) ) ,
156
+ req = new Request ( app , makeAPIGatewayRequestEvent ( { path } ) , handlerContext ( ) ) ,
158
157
chain = new RouteMatchingProcessorChain ( [ ] , '/hello/:name' ) ,
159
158
resp = new Response ( app , req , spy ( ) ) ,
160
159
done = spy ( ) ;
0 commit comments