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());