diff --git a/controllers/challenges.ts b/controllers/challenges.ts index e1fea40..18bc445 100644 --- a/controllers/challenges.ts +++ b/controllers/challenges.ts @@ -90,12 +90,12 @@ export default abstract class ChallengesController { .select({ id: challenges.id, name: challenges.name, - score: challenges.score, + score: challenges.score }) .from(challenges) .innerJoin(clubs, eq(challenges.clubId, clubs.id)) .where(eq(clubs.dailyDate, new Date())); - return dailyChallenges + return dailyChallenges; } } diff --git a/routes/daily/challenges.ts b/routes/daily/challenges.ts index 841fc36..a659ca8 100644 --- a/routes/daily/challenges.ts +++ b/routes/daily/challenges.ts @@ -14,7 +14,7 @@ export default async function Route_DailyChallenges_Get(req: Request, res: Respo return Status.send(req, next, { status: 404, error: "errors.notFound" - }) + }); } return Status.send(req, next, { diff --git a/tests/e2e/daily.test.ts b/tests/e2e/daily.test.ts index b1ff2dc..906fb21 100644 --- a/tests/e2e/daily.test.ts +++ b/tests/e2e/daily.test.ts @@ -1,107 +1,102 @@ -import createApp from "@/app"; -import globals from "@/env/env"; -import { toDateString } from "@/utils/date"; -import { get, post } from "../utils"; - -const app = createApp("e2e-daily"); - -const testGlobals = { - clubId: 0, -}; - -describe("Daily challenges", () => { - - test("should create a daily club and challenge", async () => { - const resClub = await post( - app, - "/admin/clubs", - { - name: "daily club", - avatarUrl: "https://placehold.co/400", - description: "description", - dailyDate: toDateString() // Today - }, - { - "X-ADMIN-KEY": globals.env.ADMIN_TOKEN - } - ); - - testGlobals.clubId = resClub.body.response[0].data.id ?? "invalid"; - - const res = await post( - app, - "/admin/challenges", - { - clubId: testGlobals.clubId, - score: 100, - name: "daily challenge" - }, - { - "X-ADMIN-KEY": globals.env.ADMIN_TOKEN - } - ); - - expect(res.body).toStrictEqual({ - masterStatus: 201, - sentAt: expect.any(Number), - response: [ - { - status: 201, - success: true, - data: { - id: expect.any(Number), - score: 100, - name: "daily challenge", - clubId: testGlobals.clubId - } - } - ] - }); - - }); - - - test("should get daily club", async () => { - const res = await get(app, "/daily"); - - expect(res.body).toStrictEqual({ - masterStatus: 200, - sentAt: expect.any(Number), - response: [ - { - status: 200, - success: true, - data: { - avatarUrl: "https://placehold.co/400", - name: "daily club", - description: "description" - } - } - ] - }); - - }); - - test("should get daily challenges", async () => { - const res = await get(app, "/daily/challenges"); - - expect(res.body).toStrictEqual({ - masterStatus: 200, - sentAt: expect.any(Number), - response: [ - { - status: 200, - success: true, - data: expect.arrayContaining([ - { - id: expect.any(Number), - name: expect.any(String), - score: expect.any(Number) - } - ]) - } - ] - }); - }); - -}); \ No newline at end of file +import createApp from "@/app"; +import globals from "@/env/env"; +import { toDateString } from "@/utils/date"; +import { get, post } from "../utils"; + +const app = createApp("e2e-daily"); + +const testGlobals = { + clubId: 0 +}; + +describe("Daily challenges", () => { + test("should create a daily club and challenge", async () => { + const resClub = await post( + app, + "/admin/clubs", + { + name: "daily club", + avatarUrl: "https://placehold.co/400", + description: "description", + dailyDate: toDateString() // Today + }, + { + "X-ADMIN-KEY": globals.env.ADMIN_TOKEN + } + ); + + testGlobals.clubId = resClub.body.response[0].data.id ?? "invalid"; + + const res = await post( + app, + "/admin/challenges", + { + clubId: testGlobals.clubId, + score: 100, + name: "daily challenge" + }, + { + "X-ADMIN-KEY": globals.env.ADMIN_TOKEN + } + ); + + expect(res.body).toStrictEqual({ + masterStatus: 201, + sentAt: expect.any(Number), + response: [ + { + status: 201, + success: true, + data: { + id: expect.any(Number), + score: 100, + name: "daily challenge", + clubId: testGlobals.clubId + } + } + ] + }); + }); + + test("should get daily club", async () => { + const res = await get(app, "/daily"); + + expect(res.body).toStrictEqual({ + masterStatus: 200, + sentAt: expect.any(Number), + response: [ + { + status: 200, + success: true, + data: { + avatarUrl: "https://placehold.co/400", + name: "daily club", + description: "description" + } + } + ] + }); + }); + + test("should get daily challenges", async () => { + const res = await get(app, "/daily/challenges"); + + expect(res.body).toStrictEqual({ + masterStatus: 200, + sentAt: expect.any(Number), + response: [ + { + status: 200, + success: true, + data: expect.arrayContaining([ + { + id: expect.any(Number), + name: expect.any(String), + score: expect.any(Number) + } + ]) + } + ] + }); + }); +});