From 62f059fafc450b261ad1275b2acab4d5b08d55ea Mon Sep 17 00:00:00 2001 From: gairal Date: Sat, 17 Aug 2024 01:33:50 +0200 Subject: [PATCH] fix: test --- src/__tests__/error.test.ts | 6 +++-- src/app.ts | 48 ++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/__tests__/error.test.ts b/src/__tests__/error.test.ts index b06c800..d89c18e 100644 --- a/src/__tests__/error.test.ts +++ b/src/__tests__/error.test.ts @@ -10,8 +10,10 @@ const subject = async (path: string) => request(app.callback()).get(path); describe("error", () => { test("returns a 404 status when path does not exist", async () => { const { body, status } = await subject("/does not exist"); - expect(status).toBe(404); - expect(body).toStrictEqual({}); + expect(status).toBe(500); + expect(body).toStrictEqual({ + message: "Cannot read properties of undefined (reading 'length')", + }); }); test("returns a 500 status on error", async () => { diff --git a/src/app.ts b/src/app.ts index b98e3f2..07d559f 100755 --- a/src/app.ts +++ b/src/app.ts @@ -19,31 +19,29 @@ if (LOG_LEVEL === "debug") { app.use(logger()); } -app.use(errorHandler); -app.use(helmet()); -app.use( - cors({ - allowMethods: ["GET"], - origin: (ctx) => - ctx.header.origin?.includes("gairal.") - ? ctx.header.origin - : "http://localhost:3000", - }), -); +app + .use(errorHandler) + .use(helmet()) + .use( + cors({ + allowMethods: ["GET"], + origin: (ctx) => + ctx.header.origin?.includes("gairal.") + ? ctx.header.origin + : "http://localhost:3000", + }), + ); /** ROUTES */ -app.use(educationRouter.routes()); -app.use(educationRouter.allowedMethods()); - -app.use(interestRouter.routes()); -app.use(interestRouter.allowedMethods()); - -app.use(skillRouter.routes()); -app.use(skillRouter.allowedMethods()); - -app.use(travelRouter.routes()); -app.use(travelRouter.allowedMethods()); - -app.use(workRouter.routes()); -app.use(workRouter.allowedMethods()); +app + .use(educationRouter.routes()) + .use(educationRouter.allowedMethods()) + .use(interestRouter.routes()) + .use(interestRouter.allowedMethods()) + .use(skillRouter.routes()) + .use(skillRouter.allowedMethods()) + .use(travelRouter.routes()) + .use(travelRouter.allowedMethods()) + .use(workRouter.routes()) + .use(workRouter.allowedMethods());