import { describe, expect, it, vi } from "vitest";
import { login, register } from "./authApi";

vi.mock("@shared/api/client", () => ({
  authClient: {
    post: vi.fn(async (url: string) => {
      if (url.endsWith("/login")) {
        return { data: { access_token: "token", user: { id: "1" } } };
      }
      return { data: { message: "ok" } };
    })
  }
}));

describe("authApi", () => {
  it("login returns access token payload", async () => {
    const data = await login({ email: "u@example.com", password: "Valid123" });
    expect(data.access_token).toBe("token");
  });

  it("register returns success payload", async () => {
    const data = await register({ email: "u@example.com", password: "Valid123" });
    expect(data.message).toBe("ok");
  });
});
