forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBc35a83aBurak Boduroğlu4 months ago440 commits

time.test.ts21 lines, 574 bytesHistoryRawDownload
1import { afterEach, describe, expect, it, vi } from "vitest";
2import { getTime } from "../../time";
3import { lastFetchCall, mockFetchSuccess } from "../helpers/mock-fetch";
4
5describe("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});