first commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
describe("platformApiClient runtime environment", () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllEnvs();
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it("uses VITE_PLATFORM_API_BASE_URL for the shared client", async () => {
|
||||
vi.stubEnv("VITE_PLATFORM_API_BASE_URL", "http://127.0.0.1:18080/api/v1");
|
||||
vi.resetModules();
|
||||
|
||||
const fetchMock = vi.fn(async () =>
|
||||
new Response(JSON.stringify({ items: [], count: 0 }), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" }
|
||||
})
|
||||
);
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
const { platformApiClient } = await import("./client");
|
||||
await expect(platformApiClient.listUsers()).resolves.toMatchObject({ count: 0 });
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith("http://127.0.0.1:18080/api/v1/users", expect.any(Object));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user