Skip to content

Commit 333e63f

Browse files
committed
update test specs for api parser
1 parent 34405f7 commit 333e63f

File tree

5 files changed

+32
-28
lines changed

5 files changed

+32
-28
lines changed

package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@manwaring/lambda-wrapper",
33
"description": "A lambda handler wrapper to abstract common functionality and provide useful defaults",
4-
"version": "3.5.0",
4+
"version": "3.5.1",
55
"scripts": {
66
"publish-please-dry-run": "publish-please --dry-run",
77
"publish-please": "publish-please",
@@ -22,18 +22,18 @@
2222
"@babel/preset-typescript": "^7.9.0",
2323
"@types/aws-lambda": "^8.10.51",
2424
"@types/cfn-response": "^1.0.3",
25-
"@types/jest": "^25.2.1",
26-
"@types/node": "^13.13.5",
25+
"@types/jest": "^25.2.2",
26+
"@types/node": "^14.0.1",
2727
"aws-lambda": "^1.0.6",
28-
"aws-sdk": "^2.672.0",
28+
"aws-sdk": "^2.678.0",
2929
"babel-jest": "^26.0.1",
3030
"codecov": "^3.6.5",
3131
"husky": "^4.2.5",
3232
"jest": "^26.0.1",
3333
"publish-please": "^5.5.1",
3434
"rimraf": "^3.0.2",
35-
"serverless-plugin-test-helper": "^2.1.3",
36-
"typescript": "^3.8.3"
35+
"serverless-plugin-test-helper": "^2.3.0",
36+
"typescript": "^3.9.2"
3737
},
3838
"husky": {
3939
"hooks": {

src/api/parser.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('Request parsing', () => {
5959
body: JSON.stringify({ hello: 'world' }),
6060
pathParameters: { proxy: 'not today' },
6161
queryStringParameters: { name: 'a test' },
62-
headers: { 'content-type': 'application/json', 'Test-Request': 'true' }
62+
headers: { 'content-type': 'application/json', 'Test-Request': 'true' },
6363
});
6464
const { body, path, query, auth, headers, testRequest } = new Request(event).getProperties();
6565

@@ -68,7 +68,7 @@ describe('Request parsing', () => {
6868
expect(query).toEqual({ name: 'a test' });
6969
expect(headers['content-type']).toEqual('application/json');
7070
expect(testRequest).toEqual(true);
71-
expect(auth).toBeFalsy();
71+
expect(auth).toBeTruthy();
7272
});
7373

7474
it("Get's falsy fields when optional parameters not used", () => {
@@ -82,7 +82,7 @@ describe('Request parsing', () => {
8282
expect(body).toBeFalsy();
8383
expect(path).toBeFalsy();
8484
expect(query).toBeFalsy();
85-
expect(auth).toBeFalsy();
85+
expect(auth).toBeTruthy();
8686
expect(headers).toBeFalsy();
8787
expect(testRequest).toBeFalsy();
8888
});

src/api/wrapper.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('API wrapper', () => {
4747
expect(query).toEqual({ name: 'a test' });
4848
expect(headers['content-type']).toEqual('application/json');
4949
expect(testRequest).toEqual(true);
50-
expect(auth).toBeFalsy();
50+
expect(auth).toBeTruthy();
5151
expect(success).toBeInstanceOf(Function);
5252
expect(notFound).toBeInstanceOf(Function);
5353
expect(notAuthorized).toBeInstanceOf(Function);
@@ -85,7 +85,7 @@ describe('API wrapper', () => {
8585
expect(query).toEqual({ name: 'a test' });
8686
expect(headers['content-type']).toEqual('application/json');
8787
expect(testRequest).toEqual(true);
88-
expect(auth).toBeFalsy();
88+
expect(auth).toBeTruthy();
8989
expect(success).toBeInstanceOf(Function);
9090
expect(notFound).toBeInstanceOf(Function);
9191
expect(notAuthorized).toBeInstanceOf(Function);

src/dynamodb-stream/responses.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ export function success(message: any): void {
1010

1111
export function error(error: any): void {
1212
metrics.error(error);
13-
throw new Error(error);
13+
if (error instanceof Error) {
14+
throw error;
15+
} else {
16+
throw new Error(error);
17+
}
1418
}

0 commit comments

Comments
 (0)