-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fizz-buzz-api): api gateway proxy event result version
- Loading branch information
Felix Emonds
committed
Apr 8, 2021
1 parent
64bbebb
commit 1693085
Showing
3 changed files
with
24 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
import { APIGatewayProxyEventV2, APIGatewayProxyResultV2 } from 'aws-lambda'; | ||
import { APIGatewayProxyEvent, APIGatewayProxyResult } from 'aws-lambda'; | ||
import lambdaTester from 'lambda-tester'; | ||
|
||
import fizzBuzzApiHandler from '../src'; | ||
|
||
describe('Fizz Buzz API handler', function () { | ||
test('verifies not matching response', async () => { | ||
return lambdaTester(fizzBuzzApiHandler) | ||
.event(({ body: JSON.stringify({ number: 22 }) } as unknown) as APIGatewayProxyEventV2) | ||
.expectResult((result: APIGatewayProxyResultV2<string>) => { | ||
expect(result).toStrictEqual('Not matching'); | ||
.event(({ body: JSON.stringify({ number: 22 }) } as unknown) as APIGatewayProxyEvent) | ||
.expectResult((result: APIGatewayProxyResult) => { | ||
expect(result).toStrictEqual({ body: 'Not matching', statusCode: 200 }); | ||
}); | ||
}); | ||
|
||
test('verifies fizzbuzz response', async () => { | ||
return lambdaTester(fizzBuzzApiHandler) | ||
.event(({ body: JSON.stringify({ number: 15 }) } as unknown) as APIGatewayProxyEventV2) | ||
.expectResult((result: APIGatewayProxyResultV2<string>) => { | ||
expect(result).toStrictEqual('fizzbuzz'); | ||
.event(({ body: JSON.stringify({ number: 15 }) } as unknown) as APIGatewayProxyEvent) | ||
.expectResult((result: APIGatewayProxyResult) => { | ||
expect(result).toStrictEqual({ body: 'fizzbuzz', statusCode: 200 }); | ||
}); | ||
}); | ||
|
||
test('verifies fizz response', async () => { | ||
return lambdaTester(fizzBuzzApiHandler) | ||
.event(({ body: JSON.stringify({ number: 21 }) } as unknown) as APIGatewayProxyEventV2) | ||
.expectResult((result: APIGatewayProxyResultV2<string>) => { | ||
expect(result).toStrictEqual('fizz'); | ||
.event(({ body: JSON.stringify({ number: 21 }) } as unknown) as APIGatewayProxyEvent) | ||
.expectResult((result: APIGatewayProxyResult) => { | ||
expect(result).toStrictEqual({ body: 'fizz', statusCode: 200 }); | ||
}); | ||
}); | ||
|
||
test('verifies buzz response', async () => { | ||
return lambdaTester(fizzBuzzApiHandler) | ||
.event(({ body: JSON.stringify({ number: 25 }) } as unknown) as APIGatewayProxyEventV2) | ||
.expectResult((result: APIGatewayProxyResultV2<string>) => { | ||
expect(result).toStrictEqual('buzz'); | ||
.event(({ body: JSON.stringify({ number: 25 }) } as unknown) as APIGatewayProxyEvent) | ||
.expectResult((result: APIGatewayProxyResult) => { | ||
expect(result).toStrictEqual({ body: 'buzz', statusCode: 200 }); | ||
}); | ||
}); | ||
|
||
test('verifies empty body response', async () => { | ||
return lambdaTester(fizzBuzzApiHandler) | ||
.event(({} as unknown) as APIGatewayProxyEventV2) | ||
.expectResult((result: APIGatewayProxyResultV2<string>) => { | ||
expect(result).toStrictEqual('No number!'); | ||
.event(({} as unknown) as APIGatewayProxyEvent) | ||
.expectResult((result: APIGatewayProxyResult) => { | ||
expect(result).toStrictEqual({ body: 'No number!', statusCode: 400 }); | ||
}); | ||
}); | ||
}); |