hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import { afterEach, describe, expect, it, vi } from "vitest"; |
| 2 | import { getTime } from "../../time"; |
| 3 | import { lastFetchCall, mockFetchSuccess } from "../helpers/mock-fetch"; |
| 4 | |
| 5 | describe("time API", () => { |
| 6 | afterEach(() => { |
| 7 | vi.restoreAllMocks(); |
| 8 | }); |
| 9 | |
| 10 | it("getTime calls /time", async () => { |
| 11 | const mockTime = { server_time: 1000 }; |
| 12 | mockFetchSuccess(mockTime); |
| 13 | |
| 14 | const result = await getTime(); |
| 15 | expect(result).toEqual(mockTime); |
| 16 | |
| 17 | const [url, init] = lastFetchCall(); |
| 18 | expect(url).toBe("/api/time"); |
| 19 | expect(init?.method).toBe("GET"); |
| 20 | }); |
| 21 | }); |