39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import apiContract from "../api_contract.json";
|
|
import { ApiPath } from "../api_path";
|
|
|
|
describe("ApiPath contract source", () => {
|
|
it("uses the shared contract path for every static operation", () => {
|
|
const dynamicOperations = new Set([
|
|
"privateRoomAlbumUnlock",
|
|
"privateRoomDiarySeen",
|
|
"privateRoomDiaryUnlock",
|
|
]);
|
|
const staticOperations = Object.entries(apiContract).filter(
|
|
([operationId]) => !dynamicOperations.has(operationId),
|
|
);
|
|
|
|
for (const [operationId, operation] of staticOperations) {
|
|
expect(ApiPath[operationId as keyof typeof ApiPath]).toBe(
|
|
operation.path,
|
|
);
|
|
}
|
|
});
|
|
|
|
it("fills and encodes the private album path parameter", () => {
|
|
expect(ApiPath.privateRoomAlbumUnlock("album/id 1")).toBe(
|
|
"/api/private-room/albums/album%2Fid%201/unlock",
|
|
);
|
|
});
|
|
|
|
it("fills and encodes relationship diary path parameters", () => {
|
|
expect(ApiPath.privateRoomDiarySeen("diary/id 1")).toBe(
|
|
"/api/private-room/diaries/diary%2Fid%201/seen",
|
|
);
|
|
expect(ApiPath.privateRoomDiaryUnlock("diary/id 1")).toBe(
|
|
"/api/private-room/diaries/diary%2Fid%201/unlock",
|
|
);
|
|
});
|
|
});
|