import { describe, expect, it } from "vitest";
import { buildCollections } from "./data";
import { alphabeticalBosses, defaultStatForSection, profileSectionForStat } from "./profileSections";

describe("hunter profile sections", () => {
  const bosses = alphabeticalBosses(buildCollections({ dropsFound: {}, petsFound: {} }, {}));

  it("groups related records under one section", () => {
    expect(profileSectionForStat("blockbreaker-bricks")).toBe("blockbreaker");
    expect(profileSectionForStat("blockbreaker-time")).toBe("blockbreaker");
    expect(profileSectionForStat("hockey-pvp-boss-kills")).toBe("hockey-pvp");
    expect(profileSectionForStat("aether-assault")).toBe("aether-assault");
    expect(profileSectionForStat("bulldrome")).toBe("bosses");
  });

  it("builds one alphabetical boss index across mechanic groups", () => {
    const names = bosses.map((boss) => boss.bossName);
    expect(names).toEqual([...names].sort((left, right) => left.localeCompare(right)));
    expect(new Set(bosses.map((boss) => boss.bossId)).size).toBe(bosses.length);
  });

  it("opens each section on its primary record", () => {
    expect(defaultStatForSection("hockey-pvp", bosses)).toBe("hockey-pvp-wins");
    expect(defaultStatForSection("blockbreaker", bosses)).toBe("blockbreaker-score");
    expect(defaultStatForSection("aether-assault", bosses)).toBe("aether-assault");
    expect(defaultStatForSection("bosses", bosses)).toBe(bosses[0].bossId);
  });
});
