Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
chore: Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ardalanamini committed Jan 31, 2021
1 parent d91ae38 commit 5650b76
Show file tree
Hide file tree
Showing 4 changed files with 212 additions and 198 deletions.
45 changes: 18 additions & 27 deletions __tests__/lookup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { inject } from "./__internals__";
import Router from "../src";

it("should call the handler", async () => {
expect.assertions(3);
expect.assertions(2);

const router = new Router();

Expand All @@ -12,16 +12,15 @@ it("should call the handler", async () => {
router.get(path, handler);

const {
raw: { req, res },
raw: { req },
} = await inject(router, path);

expect(handler).toBeCalledTimes(1);
expect(res.getHeader("Allow")).toBe("GET");
expect(req.params).toEqual({});
});

it("should call the middleware & then the handler", async () => {
expect.assertions(4);
expect.assertions(3);

const router = new Router();

Expand All @@ -32,17 +31,16 @@ it("should call the middleware & then the handler", async () => {
router.get(path, middleware, handler);

const {
raw: { req, res },
raw: { req },
} = await inject(router, path);

expect(middleware).toBeCalledTimes(1);
expect(handler).toBeCalledTimes(1);
expect(res.getHeader("Allow")).toBe("GET");
expect(req.params).toEqual({});
});

it("should respond with 404 status", async () => {
expect.assertions(4);
expect.assertions(3);

const router = new Router();

Expand All @@ -52,12 +50,11 @@ it("should respond with 404 status", async () => {
router.get(path, handler);

const {
raw: { req, res },
raw: { req },
statusCode,
} = await inject(router, path);

expect(handler).toBeCalledTimes(1);
expect(res.getHeader("Allow")).toBe("GET");
expect(req.params).toEqual({});
expect(statusCode).toBe(404);
});
Expand All @@ -84,7 +81,7 @@ it("should respond with 405 status", async () => {
});

it("should call the error handler", async () => {
expect.assertions(5);
expect.assertions(4);

const router = new Router();

Expand All @@ -101,19 +98,18 @@ it("should call the error handler", async () => {
router.catch(errorHandler);

const {
raw: { req, res },
raw: { req },
body,
} = await inject(router, path);

expect(handler).toBeCalledTimes(1);
expect(errorHandler).toBeCalledTimes(1);
expect(res.getHeader("Allow")).toBe("GET");
expect(req.params).toEqual({});
expect(body).toEqual("TEST");
});

it("should call the error handler if next is called with an error", async () => {
expect.assertions(5);
expect.assertions(4);

const router = new Router();

Expand All @@ -130,19 +126,18 @@ it("should call the error handler if next is called with an error", async () =>
router.catch(errorHandler);

const {
raw: { req, res },
raw: { req },
body,
} = await inject(router, path);

expect(handler).toBeCalledTimes(1);
expect(errorHandler).toBeCalledTimes(1);
expect(res.getHeader("Allow")).toBe("GET");
expect(req.params).toEqual({});
expect(body).toEqual("TEST");
});

it("should catch Promise errors", async () => {
expect.assertions(5);
expect.assertions(4);

const router = new Router();

Expand All @@ -159,19 +154,18 @@ it("should catch Promise errors", async () => {
router.catch(errorHandler);

const {
raw: { req, res },
raw: { req },
body,
} = await inject(router, path);

expect(handler).toBeCalledTimes(1);
expect(errorHandler).toBeCalledTimes(1);
expect(res.getHeader("Allow")).toBe("GET");
expect(req.params).toEqual({});
expect(body).toEqual("TEST");
});

it("should fallback to the default error handler", async () => {
expect.assertions(5);
expect.assertions(4);

const router = new Router();

Expand All @@ -188,7 +182,7 @@ it("should fallback to the default error handler", async () => {
router.catch(errorHandler);

const {
raw: { req, res },
raw: { req },
body,
} = await inject(router, {
url: path,
Expand All @@ -199,13 +193,12 @@ it("should fallback to the default error handler", async () => {

expect(handler).toBeCalledTimes(1);
expect(errorHandler).toBeCalledTimes(1);
expect(res.getHeader("Allow")).toBe("GET");
expect(req.params).toEqual({});
expect(body).toEqual("DAMN");
});

it("should fallback to the default error handler (Promise)", async () => {
expect.assertions(5);
expect.assertions(4);

const router = new Router();

Expand All @@ -222,7 +215,7 @@ it("should fallback to the default error handler (Promise)", async () => {
router.catch(errorHandler);

const {
raw: { req, res },
raw: { req },
body,
} = await inject(router, {
url: path,
Expand All @@ -233,13 +226,12 @@ it("should fallback to the default error handler (Promise)", async () => {

expect(handler).toBeCalledTimes(1);
expect(errorHandler).toBeCalledTimes(1);
expect(res.getHeader("Allow")).toBe("GET");
expect(req.params).toEqual({});
expect(body).toEqual("DAMN");
});

it("should fallback to the default error handler if next is called with an error in one of the registered error handlers", async () => {
expect.assertions(5);
expect.assertions(4);

const router = new Router();

Expand All @@ -256,7 +248,7 @@ it("should fallback to the default error handler if next is called with an error
router.catch(errorHandler);

const {
raw: { req, res },
raw: { req },
body,
} = await inject(router, {
url: path,
Expand All @@ -267,7 +259,6 @@ it("should fallback to the default error handler if next is called with an error

expect(handler).toBeCalledTimes(1);
expect(errorHandler).toBeCalledTimes(1);
expect(res.getHeader("Allow")).toBe("GET");
expect(req.params).toEqual({});
expect(body).toEqual("DAMN");
});
Loading

0 comments on commit 5650b76

Please sign in to comment.