Skip to content

Commit

Permalink
Self-review
Browse files Browse the repository at this point in the history
  • Loading branch information
Shillaker committed Nov 6, 2023
1 parent 0e66cb7 commit 97eca45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

To test your local version of this package, you can use [`npm link`](https://docs.npmjs.com/cli/v6/commands/npm-link).

You can do this quickly from the `examples` directory with:
You can do this from the `examples` directory with:

```sh
cd examples
Expand All @@ -13,7 +13,7 @@ node with_object/handler.js

## Tests

You can run tests locall with:
You can run tests locally with:

```sh
npm test
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
"dependencies": {
"@fastify/url-data": "^5.3.1",
"@types/node": "^20.1.4",
"fastify": "^4.15.0",
"v8": "^0.1.0"
"fastify": "^4.15.0"
},
"devDependencies": {
"@types/jest": "^29.5.7",
"jest": "^29.7.0",
"node-fetch": "^3.3.2",
"prettier": "3.0.3",
"ts-jest": "^29.1.1",
"typescript": "^5.0.4"
Expand Down
10 changes: 5 additions & 5 deletions tests/requests.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { FastifyInstance } from "fastify";
import { serveHandler } from "../framework/local/index";
import { Event, Callback, Context, Handler } from "../framework/types/types";
import { Event, Callback, Context } from "../framework/types/types";

function handler(event: Event, context: Context, callback: Callback) {
return {
body: "Hello from a " + event.httpMethod + " request",
};
}

describe("testing index file", () => {
describe("Test local server can handle different request types", () => {
let server: FastifyInstance;

// Applies only to tests in this describe block
beforeEach(async () => {
// Start the server
server = serveHandler(handler, 8080);
await server.ready();
});

test("Check GET request", async () => {
test("GET request response", async () => {
// Make request
const response = await fetch("http://localhost:8080", {
method: "GET",
Expand All @@ -27,7 +27,7 @@ describe("testing index file", () => {
expect(responseText).toBe("Hello from a GET request");
});

test("Check POST request", async () => {
test("POST request response", async () => {
// Make request
let data = { foo: "bar" };
const response = await fetch("http://localhost:8080", {
Expand Down

0 comments on commit 97eca45

Please sign in to comment.