forked from baron/baron-sso
20 lines
547 B
TypeScript
20 lines
547 B
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { fetchMe } from "./authApi";
|
|
|
|
const getMock = vi.fn();
|
|
|
|
vi.mock("../../lib/apiClient", () => ({
|
|
default: {
|
|
get: (...args: unknown[]) => getMock(...args),
|
|
},
|
|
}));
|
|
|
|
describe("fetchMe", () => {
|
|
it("returns the response payload from the API client", async () => {
|
|
getMock.mockResolvedValueOnce({ data: { id: "user-1", name: "Dev" } });
|
|
|
|
await expect(fetchMe()).resolves.toEqual({ id: "user-1", name: "Dev" });
|
|
expect(getMock).toHaveBeenCalledWith("/user/me");
|
|
});
|
|
});
|