forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB7122d71Burak Boduroğlu4 months ago419 commits

limits.test.ts19 lines, 624 bytesHistoryRawDownload
1import { afterEach, describe, expect, it, vi } from "vitest";
2import { getLimits, setCachedLimits } from "../../limits";
3import { lastFetchCall, mockFetchSuccess } from "../helpers/mock-fetch";
4
5describe("limits API", () => {
6 afterEach(() => {
7 vi.restoreAllMocks();
8 setCachedLimits(null);
9 });
10
11 it("loads /limits once and caches it", async () => {
12 mockFetchSuccess({ user: { min_username_len: 3 } });
13 await getLimits();
14 expect(lastFetchCall()[0]).toBe("/api/limits");
15 vi.mocked(globalThis.fetch).mockClear();
16 await getLimits();
17 expect(globalThis.fetch).not.toHaveBeenCalled();
18 });
19});