Skip to content

Commit 5005a8c

Browse files
committed
refactor: replace usage of apiGatewayRequest by new makeAPIGatewayRequestEvent where
_.extends was applied
1 parent 02b6d8f commit 5005a8c

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

tests/chains/RouteMatchingProcessorChain.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import _ from 'underscore';
21
import { Application, Request, Response } from '../../src';
3-
import { apiGatewayRequest, handlerContext } from '../samples';
2+
import { handlerContext, makeAPIGatewayRequestEvent } from '../samples';
43
import { expect } from 'chai';
54
import { RouteMatchingProcessorChain } from '../../src/chains/RouteMatchingProcessorChain';
65
import { PathParams } from '../../src/interfaces';
@@ -22,7 +21,7 @@ describe('RouteMatchingProcessorChain', () => {
2221
describe('matches', () => {
2322
const test = (method: string | undefined, routes: PathParams, path: string, expectation: boolean, caseSensitive = false): void => {
2423
let app = new Application(),
25-
req = new Request(app, _.extend(apiGatewayRequest(), { path: path }), handlerContext()),
24+
req = new Request(app, makeAPIGatewayRequestEvent({ path: path }), handlerContext()),
2625
chain = new RouteMatchingProcessorChain([], routes, method, caseSensitive);
2726

2827
expect(chain.matches(req)).to.eql(expectation);
@@ -138,7 +137,7 @@ describe('RouteMatchingProcessorChain', () => {
138137
describe('makeSubRequest', () => {
139138
const test = (routes: PathParams, path: string, expectation: StringMap): void => {
140139
let app = new Application(),
141-
req = new Request(app, _.extend(apiGatewayRequest(), { path: path }), handlerContext()),
140+
req = new Request(app, makeAPIGatewayRequestEvent({ path: path }), handlerContext()),
142141
chain = new TestRouteMatchingProcessorChain([], routes),
143142
subReq = chain._makeSubRequest(req);
144143

@@ -154,7 +153,7 @@ describe('RouteMatchingProcessorChain', () => {
154153
// sending this character using UTF-8 encoding (i.e. %C3%AA)
155154
const path = '/hello/%EA',
156155
app = new Application(),
157-
req = new Request(app, _.extend(apiGatewayRequest(), { path }), handlerContext()),
156+
req = new Request(app, makeAPIGatewayRequestEvent({ path }), handlerContext()),
158157
chain = new RouteMatchingProcessorChain([], '/hello/:name'),
159158
resp = new Response(app, req, spy()),
160159
done = spy();

tests/chains/SubRouterProcessorChain.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import _ from 'underscore';
21
import { Application, Request, Router, Response } from '../../src';
3-
import { apiGatewayRequest, handlerContext } from '../samples';
2+
import { handlerContext, makeAPIGatewayRequestEvent } from '../samples';
43
import { expect } from 'chai';
54
import { PathParams, NextCallback } from '../../src/interfaces';
65
import { SinonSpy, spy, assert } from 'sinon';
@@ -27,7 +26,7 @@ describe('SubRouterProcessorChain', () => {
2726
describe('matches', () => {
2827
const test = (routes: PathParams, path: string, expectation: boolean): void => {
2928
let app = new Application(),
30-
req = new Request(app, _.extend(apiGatewayRequest(), { path: path }), handlerContext()),
29+
req = new Request(app, makeAPIGatewayRequestEvent({ path: path }), handlerContext()),
3130
router = new TestRouter(spy()),
3231
chain = new SubRouterProcessorChain(routes, router, app.routerOptions);
3332

@@ -53,7 +52,7 @@ describe('SubRouterProcessorChain', () => {
5352
describe('run', () => {
5453
const test = (routes: PathParams, path: string, baseURL: string): void => {
5554
let app = new Application(),
56-
req = new Request(app, _.extend(apiGatewayRequest(), { path: path }), handlerContext()),
55+
req = new Request(app, makeAPIGatewayRequestEvent({ path: path }), handlerContext()),
5756
resp = new Response(app, req, spy()),
5857
done = spy(),
5958
handle = spy(),

0 commit comments

Comments
 (0)