import { describe, expect, it } from "vitest";
import { highestEndlessBossKillsAfterDefeat, highestRoguelikeRoundAfterDefeat } from "./hunterStats";

describe("roguelike hunter records", () => {
  it("records the reached defeat round without lowering a previous best", () => {
    expect(highestRoguelikeRoundAfterDefeat(0, 1)).toBe(1);
    expect(highestRoguelikeRoundAfterDefeat(7, 12)).toBe(12);
    expect(highestRoguelikeRoundAfterDefeat(12, 7)).toBe(12);
  });

  it("normalizes invalid and fractional round values", () => {
    expect(highestRoguelikeRoundAfterDefeat(Number.NaN, Number.NaN)).toBe(1);
    expect(highestRoguelikeRoundAfterDefeat(4.9, 8.9)).toBe(8);
  });
});

describe("Rogue Trials endless hunter records", () => {
  it("keeps the highest boss count from one endless run", () => {
    expect(highestEndlessBossKillsAfterDefeat(0, 17)).toBe(17);
    expect(highestEndlessBossKillsAfterDefeat(17, 9)).toBe(17);
    expect(highestEndlessBossKillsAfterDefeat(17, 23)).toBe(23);
  });

  it("normalizes invalid and fractional kill counts", () => {
    expect(highestEndlessBossKillsAfterDefeat(Number.NaN, Number.NaN)).toBe(0);
    expect(highestEndlessBossKillsAfterDefeat(4.9, 8.9)).toBe(8);
  });
});
