Files
musicmouse/web/src/api/__tests__/client.test.ts

21 lines
704 B
TypeScript

import { describe, expect, it } from "vitest";
import { coverUrl } from "../client";
describe("coverUrl", () => {
it("is the plain full-size URL with no options", () => {
expect(coverUrl("abc")).toBe("/api/albums/abc/cover");
});
it("asks for the thumbnail and carries the cache-busting version", () => {
expect(coverUrl("abc", { size: "thumb", version: 42 })).toBe(
"/api/albums/abc/cover?size=thumb&v=42",
);
});
it("leaves the version off when there is none, so the server revalidates", () => {
expect(coverUrl("abc", { size: "thumb" })).toBe("/api/albums/abc/cover?size=thumb");
expect(coverUrl("abc", { version: 0 })).toBe("/api/albums/abc/cover");
});
});