import { describe, expect, it } from "vitest";
import { applyAuthHeader, setAccessTokenGetter } from "./client";

describe("apiClient auth header", () => {
  it("attaches bearer token from getter", () => {
    setAccessTokenGetter(() => "test-token");
    const headers = applyAuthHeader({});
    expect(headers.Authorization).toBe("Bearer test-token");
  });

  it("leaves headers unchanged without token", () => {
    setAccessTokenGetter(() => null);
    const headers = applyAuthHeader({ "X-Test": "1" });
    expect(headers).toEqual({ "X-Test": "1" });
  });
});
