mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-11 14:13:35 +08:00
chore: add test for recordClientVersion (@fehmer) (#5746)
This commit is contained in:
parent
0a0f175291
commit
45d27b5e00
2 changed files with 19 additions and 3 deletions
|
@ -1,15 +1,18 @@
|
|||
import request from "supertest";
|
||||
import app from "../../../src/app";
|
||||
import * as PsaDal from "../../../src/dal/psa";
|
||||
import * as Prometheus from "../../../src/utils/prometheus";
|
||||
import { ObjectId } from "mongodb";
|
||||
const mockApp = request(app);
|
||||
|
||||
describe("Psa Controller", () => {
|
||||
describe("get psa", () => {
|
||||
const getPsaMock = vi.spyOn(PsaDal, "get");
|
||||
const recordClientVersionMock = vi.spyOn(Prometheus, "recordClientVersion");
|
||||
|
||||
afterEach(() => {
|
||||
getPsaMock.mockReset();
|
||||
recordClientVersionMock.mockReset();
|
||||
});
|
||||
|
||||
it("get psas without authorization", async () => {
|
||||
|
@ -53,6 +56,8 @@ describe("Psa Controller", () => {
|
|||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(recordClientVersionMock).toHaveBeenCalledWith("unknown");
|
||||
});
|
||||
it("get psas with authorization", async () => {
|
||||
await mockApp
|
||||
|
@ -60,5 +65,16 @@ describe("Psa Controller", () => {
|
|||
.set("authorization", `Uid 123456789`)
|
||||
.expect(200);
|
||||
});
|
||||
|
||||
it("get psas records x-client-version", async () => {
|
||||
await mockApp.get("/psas").set("x-client-version", "1.0").expect(200);
|
||||
|
||||
expect(recordClientVersionMock).toHaveBeenCalledWith("1.0");
|
||||
});
|
||||
it("get psas records client-version", async () => {
|
||||
await mockApp.get("/psas").set("client-version", "2.0").expect(200);
|
||||
|
||||
expect(recordClientVersionMock).toHaveBeenCalledWith("2.0");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ export const presetsContract = c.router(
|
|||
summary: "get presets",
|
||||
description: "Get presets of the current user.",
|
||||
method: "GET",
|
||||
path: "/",
|
||||
path: "",
|
||||
responses: {
|
||||
200: GetPresetResponseSchema,
|
||||
},
|
||||
|
@ -43,7 +43,7 @@ export const presetsContract = c.router(
|
|||
summary: "add preset",
|
||||
description: "Add a new preset for the current user.",
|
||||
method: "POST",
|
||||
path: "/",
|
||||
path: "",
|
||||
body: AddPresetRequestSchema.strict(),
|
||||
responses: {
|
||||
200: AddPresetResponseSchemna,
|
||||
|
@ -53,7 +53,7 @@ export const presetsContract = c.router(
|
|||
summary: "update preset",
|
||||
description: "Update an existing preset for the current user.",
|
||||
method: "PATCH",
|
||||
path: "/",
|
||||
path: "",
|
||||
body: PresetSchema.strict(),
|
||||
responses: {
|
||||
200: MonkeyResponseSchema,
|
||||
|
|
Loading…
Reference in a new issue