import { describe, expect, it, beforeEach, afterEach } from "vitest";
import {
  hostPublicDefaultCustomerId,
  isHostPublicApiEnabled,
} from "@/lib/constants/host-public-api";

describe("host public api env", () => {
  const prevEnabled = process.env.HOST_PUBLIC_API_ENABLED;
  const prevCustomer = process.env.HOST_PUBLIC_DEFAULT_CUSTOMER_ID;

  afterEach(() => {
    process.env.HOST_PUBLIC_API_ENABLED = prevEnabled;
    process.env.HOST_PUBLIC_DEFAULT_CUSTOMER_ID = prevCustomer;
  });

  it("is disabled by default", () => {
    delete process.env.HOST_PUBLIC_API_ENABLED;
    expect(isHostPublicApiEnabled()).toBe(false);
  });

  it("reads enabled flag and default customer", () => {
    process.env.HOST_PUBLIC_API_ENABLED = "true";
    process.env.HOST_PUBLIC_DEFAULT_CUSTOMER_ID = "CUST_MEIMEI";
    expect(isHostPublicApiEnabled()).toBe(true);
    expect(hostPublicDefaultCustomerId()).toBe("CUST_MEIMEI");
  });
});
