Skip to content

Commit

Permalink
Fix failing tests for raw queries
Browse files Browse the repository at this point in the history
  • Loading branch information
HansGabriel committed Dec 9, 2023
1 parent 5b112bb commit 52bfdbd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
24 changes: 12 additions & 12 deletions packages/api/src/router/tests/testQueries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,25 @@ describe("testRouter - queries", () => {
beforeEach(async () => {
ctx.prisma.$queryRaw = vi.fn().mockResolvedValue([
{
firstName: "John",
imageUrl: "img1.jpg",
user_first_name: "John",
user_image_url: "img1.jpg",
id: "playerId1",
createdAt: new Date("2023-01-10T10:00:00Z"),
highScore: 95,
play_created_at: new Date("2023-01-10T10:00:00Z"),
high_score: 95,
},
{
firstName: "Doe",
imageUrl: "img2.jpg",
user_first_name: "Doe",
user_image_url: "img2.jpg",
id: "playerId2",
createdAt: new Date("2023-01-05T10:00:00Z"),
highScore: 89,
play_created_at: new Date("2023-01-05T10:00:00Z"),
high_score: 89,
},
{
firstName: "Alice",
imageUrl: "img3.jpg",
user_first_name: "Alice",
user_image_url: "img3.jpg",
id: "playerId3",
createdAt: new Date("2023-01-08T10:00:00Z"),
highScore: 92,
play_created_at: new Date("2023-01-08T10:00:00Z"),
high_score: 92,
},
]);
});
Expand Down
48 changes: 24 additions & 24 deletions packages/api/src/router/tests/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,30 +172,30 @@ describe("useRouter", () => {
expect(ctx.prisma.$queryRaw).toHaveBeenCalledWith(
//Note: the next lines `SELECT...LIMIT 3;` are CASE, SPACE, and NEXT-LINE SENSITIVE
Prisma.sql`
SELECT
DISTINCT ON ("Play"."playerId")
"User"."firstName",
"User"."imageUrl",
"Play"."playerId" AS "id",
MAX("Play"."score") AS "highScore"
FROM
"Play"
JOIN
"User"
ON
"Play"."playerId" = "User"."userId"
WHERE
"Play"."isFinished" = TRUE
AND "Play"."testId" = ${item.testId}
GROUP BY
"Play"."playerId",
"User"."firstName",
"User"."imageUrl"
ORDER BY
"Play"."playerId",
"highScore" DESC
LIMIT 3;
`,
SELECT
DISTINCT ON ("play"."player_id")
"user"."user_first_name",
"user"."user_image_url",
"play"."player_id" AS "id",
MAX("play"."play_score") AS "high_score"
FROM
"play"
JOIN
"user"
ON
"play"."player_id" = "user"."clerk_user_id"
WHERE
"play"."play_is_finished" = TRUE
AND "play"."test_id" = ${item.testId}
GROUP BY
"play"."player_id",
"user"."user_first_name",
"user"."user_image_url"
ORDER BY
"play"."player_id",
"high_score" DESC
LIMIT 3;
`,
);
},
{ concurrency: 5 },
Expand Down

0 comments on commit 52bfdbd

Please sign in to comment.