Skip to content

Commit

Permalink
fix: prettier format
Browse files Browse the repository at this point in the history
  • Loading branch information
Drixares committed Nov 2, 2024
1 parent 3296ea5 commit fd2d8e5
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 110 deletions.
4 changes: 2 additions & 2 deletions controllers/challenges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion routes/daily/challenges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
209 changes: 102 additions & 107 deletions tests/e2e/daily.test.ts
Original file line number Diff line number Diff line change
@@ -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)
}
])
}
]
});
});

});
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)
}
])
}
]
});
});
});

0 comments on commit fd2d8e5

Please sign in to comment.