Skip to content

Commit

Permalink
impr: use tsrest for user endpoints (@fehmer) (#5815)
Browse files Browse the repository at this point in the history
!nuf
  • Loading branch information
fehmer authored Sep 5, 2024
1 parent 6a24dbb commit 259894a
Show file tree
Hide file tree
Showing 81 changed files with 5,297 additions and 3,332 deletions.
14 changes: 13 additions & 1 deletion backend/__tests__/api/controllers/dev.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import request from "supertest";
import app from "../../../src/app";

import * as AuthUtils from "../../../src/utils/auth";
import { ObjectId } from "mongodb";
import * as Misc from "../../../src/utils/misc";
import { DecodedIdToken } from "firebase-admin/auth";

const uid = new ObjectId().toHexString();
const mockDecodedToken = {
uid,
email: "newuser@mail.com",
iat: 0,
} as DecodedIdToken;
const mockApp = request(app);

describe("DevController", () => {
const verifyIdTokenMock = vi.spyOn(AuthUtils, "verifyIdToken");
beforeEach(() => {
verifyIdTokenMock.mockReset().mockResolvedValue(mockDecodedToken);
});

describe("generate testData", () => {
const isDevEnvironmentMock = vi.spyOn(Misc, "isDevEnvironment");

Expand All @@ -22,6 +33,7 @@ describe("DevController", () => {
//WHEN
const { body } = await mockApp
.post("/dev/generateData")
.set("Authorization", "Bearer 123456789")
.send({ username: "test" })
.expect(503);
//THEN
Expand Down
8 changes: 4 additions & 4 deletions backend/__tests__/api/controllers/leaderboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe("Loaderboard Controller", () => {
validationErrors: [
'"language" Required',
'"mode" Required',
'"mode2" Needs to be either a number, "zen" or "custom."',
'"mode2" Needs to be either a number, "zen" or "custom".',
],
});
});
Expand Down Expand Up @@ -320,7 +320,7 @@ describe("Loaderboard Controller", () => {
validationErrors: [
'"language" Required',
'"mode" Required',
'"mode2" Needs to be either a number, "zen" or "custom."',
'"mode2" Needs to be either a number, "zen" or "custom".',
],
});
});
Expand Down Expand Up @@ -591,7 +591,7 @@ describe("Loaderboard Controller", () => {
validationErrors: [
'"language" Required',
'"mode" Required',
'"mode2" Needs to be either a number, "zen" or "custom."',
'"mode2" Needs to be either a number, "zen" or "custom".',
],
});
});
Expand Down Expand Up @@ -768,7 +768,7 @@ describe("Loaderboard Controller", () => {
validationErrors: [
'"language" Required',
'"mode" Required',
'"mode2" Needs to be either a number, "zen" or "custom."',
'"mode2" Needs to be either a number, "zen" or "custom".',
],
});
});
Expand Down
2 changes: 1 addition & 1 deletion backend/__tests__/api/controllers/public.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("PublicController", () => {
validationErrors: [
'"language" Required',
'"mode" Required',
'"mode2" Needs to be either a number, "zen" or "custom."',
'"mode2" Needs to be either a number, "zen" or "custom".',
],
});
});
Expand Down
Loading

0 comments on commit 259894a

Please sign in to comment.