hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB7122d71Burak Boduroğlu4 months ago419 commits
| 1 | import { afterEach, describe, expect, it, vi } from "vitest"; |
| 2 | import { getLimits, setCachedLimits } from "../../limits"; |
| 3 | import { lastFetchCall, mockFetchSuccess } from "../helpers/mock-fetch"; |
| 4 | |
| 5 | describe("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 | }); |