import { afterEach, describe, expect, it } from "vitest";
import { isHostServiceAuthDisabled } from "@/lib/constants/host-service";

describe("isHostServiceAuthDisabled", () => {
  const env = process.env;

  afterEach(() => {
    process.env = { ...env };
  });

  it("production 始终需鉴权", () => {
    process.env.NODE_ENV = "production";
    process.env.HOST_SERVICE_AUTH_DISABLED = "true";
    expect(isHostServiceAuthDisabled()).toBe(false);
  });

  it("development 默认跳过宿主 Token", () => {
    process.env.NODE_ENV = "development";
    delete process.env.HOST_SERVICE_AUTH_DISABLED;
    expect(isHostServiceAuthDisabled()).toBe(true);
  });

  it("development 可显式开启鉴权", () => {
    process.env.NODE_ENV = "development";
    process.env.HOST_SERVICE_AUTH_DISABLED = "false";
    expect(isHostServiceAuthDisabled()).toBe(false);
  });
});
