hezarfen_frontend
Clone
https://git.tahinli.com/Hezarfen/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { afterEach, describe, expect, it, vi } from "vitest"; |
| 2 | import { getSchool } from "../../school"; |
| 3 | import { lastFetchCall, mockFetchSuccess } from "../helpers/mock-fetch"; |
| 4 | |
| 5 | describe("school API", () => { |
| 6 | afterEach(() => { |
| 7 | vi.restoreAllMocks(); |
| 8 | }); |
| 9 | |
| 10 | it("getSchool reads the session's school from /school", async () => { |
| 11 | const identity = { id: "01a0b0a5-ffb5-7682-8726-7e4ef1a5c68d", name: "Ata Koleji" }; |
| 12 | mockFetchSuccess(identity); |
| 13 | |
| 14 | const result = await getSchool(); |
| 15 | expect(result).toEqual(identity); |
| 16 | |
| 17 | const [url, init] = lastFetchCall(); |
| 18 | expect(url).toBe("/api/school"); |
| 19 | expect(init?.method).toBe("GET"); |
| 20 | }); |
| 21 | }); |