import { describe, expect, test } from "bun:test";

import { getAvailabilityProgressColor } from "../../../src/web/constants/color-threshold";

describe("color-threshold", () => {
  describe("getAvailabilityProgressColor", () => {
    test("首档（0-10%）和末档（90-100%）", () => {
      expect(getAvailabilityProgressColor(0)).toBe("var(--avail-0)");
      expect(getAvailabilityProgressColor(5)).toBe("var(--avail-0)");
      expect(getAvailabilityProgressColor(90)).toBe("var(--avail-9)");
      expect(getAvailabilityProgressColor(95)).toBe("var(--avail-9)");
      expect(getAvailabilityProgressColor(100)).toBe("var(--avail-9)");
    });

    test("所有边界值（每档切换点）", () => {
      expect(getAvailabilityProgressColor(9.99)).toBe("var(--avail-0)");
      expect(getAvailabilityProgressColor(10)).toBe("var(--avail-1)");
      expect(getAvailabilityProgressColor(19.99)).toBe("var(--avail-1)");
      expect(getAvailabilityProgressColor(20)).toBe("var(--avail-2)");
      expect(getAvailabilityProgressColor(29.99)).toBe("var(--avail-2)");
      expect(getAvailabilityProgressColor(30)).toBe("var(--avail-3)");
      expect(getAvailabilityProgressColor(39.99)).toBe("var(--avail-3)");
      expect(getAvailabilityProgressColor(40)).toBe("var(--avail-4)");
      expect(getAvailabilityProgressColor(49.99)).toBe("var(--avail-4)");
      expect(getAvailabilityProgressColor(50)).toBe("var(--avail-5)");
      expect(getAvailabilityProgressColor(59.99)).toBe("var(--avail-5)");
      expect(getAvailabilityProgressColor(60)).toBe("var(--avail-6)");
      expect(getAvailabilityProgressColor(69.99)).toBe("var(--avail-6)");
      expect(getAvailabilityProgressColor(70)).toBe("var(--avail-7)");
      expect(getAvailabilityProgressColor(79.99)).toBe("var(--avail-7)");
      expect(getAvailabilityProgressColor(80)).toBe("var(--avail-8)");
      expect(getAvailabilityProgressColor(89.99)).toBe("var(--avail-8)");
      expect(getAvailabilityProgressColor(90)).toBe("var(--avail-9)");
    });
  });
});
