import { beforeEach, describe, expect, it, vi } from "vitest";
import {
  getHostQuotePollIntervalMs,
  HOST_QUOTE_POLL_INTERVAL_MS_DEFAULT,
} from "@/lib/constants/host-public-api";

describe("getHostQuotePollIntervalMs", () => {
  beforeEach(() => {
    vi.unstubAllEnvs();
  });

  it("默认 500ms", () => {
    expect(HOST_QUOTE_POLL_INTERVAL_MS_DEFAULT).toBe(500);
    expect(getHostQuotePollIntervalMs()).toBe(500);
  });

  it("支持 HOST_QUOTE_POLL_INTERVAL_MS 覆盖", () => {
    vi.stubEnv("HOST_QUOTE_POLL_INTERVAL_MS", "800");
    expect(getHostQuotePollIntervalMs()).toBe(800);
  });

  it("非法值回退默认", () => {
    vi.stubEnv("HOST_QUOTE_POLL_INTERVAL_MS", "0");
    expect(getHostQuotePollIntervalMs()).toBe(500);
  });
});
