import { describe, expect, it } from "vitest";
import {
  STAFF_CAST_AFTERGLOW_SECONDS,
  STAFF_CAST_GLOW_PROFILES,
  isHealerPulseKind,
  staffCastGlowStrength,
} from "./staffCastGlow";

describe("staff cast glow", () => {
  it("uses a distinct color for every healer class", () => {
    expect(STAFF_CAST_GLOW_PROFILES.priest.color).toBe("#ffd66b");
    expect(STAFF_CAST_GLOW_PROFILES.druid.color).toBe("#72df72");
    expect(STAFF_CAST_GLOW_PROFILES.shaman.color).toBe("#62bdff");
    expect(STAFF_CAST_GLOW_PROFILES.paladin.color).toBe("#f2a65a");
    expect(STAFF_CAST_GLOW_PROFILES.chronomancer.color).toBe("#62d4d9");
    expect(new Set(Object.values(STAFF_CAST_GLOW_PROFILES).map((profile) => profile.color)).size).toBe(5);
  });

  it("accepts every healer cast pulse and rejects encounter pulses", () => {
    for (const kind of ["direct-heal", "periodic-heal", "protective", "cleanse", "group-heal", "field"] as const) {
      expect(isHealerPulseKind(kind)).toBe(true);
    }
    expect(isHealerPulseKind("boss")).toBe(false);
    expect(isHealerPulseKind("venom")).toBe(false);
  });

  it("ramps during a cast, flashes on completion, then fades out", () => {
    const castStart = staffCastGlowStrength({ castingProgress: 0, afterglowAge: null });
    const castEnd = staffCastGlowStrength({ castingProgress: 1, afterglowAge: null });
    const completed = staffCastGlowStrength({ castingProgress: null, afterglowAge: 0 });
    const fading = staffCastGlowStrength({ castingProgress: null, afterglowAge: STAFF_CAST_AFTERGLOW_SECONDS / 2 });
    const finished = staffCastGlowStrength({ castingProgress: null, afterglowAge: STAFF_CAST_AFTERGLOW_SECONDS });

    expect(castStart).toBeGreaterThan(0);
    expect(castEnd).toBeGreaterThan(castStart);
    expect(completed).toBe(1);
    expect(fading).toBeGreaterThan(0);
    expect(fading).toBeLessThan(completed);
    expect(finished).toBe(0);
  });

  it("stays dark without an active or completed cast", () => {
    expect(staffCastGlowStrength({ castingProgress: null, afterglowAge: null })).toBe(0);
  });
});
