import { describe, expect, it } from "vitest";
import { harvillePlacementProbabilities } from "../brackt-simulator";

describe("BracktSimulator", () => {
  it("returns uniform placement probabilities when all weights are zero", () => {
    const probabilities = harvillePlacementProbabilities([0, 0, 0, 0, 0, 0]);

    expect(probabilities).toHaveLength(6);
    for (const row of probabilities) {
      expect(row).toHaveLength(6);
      for (const probability of row) {
        expect(probability).toBeCloseTo(1 / 6, 5);
      }
    }
  });

  it("gives higher first-place probability to higher projected weights", () => {
    const probabilities = harvillePlacementProbabilities([10, 20, 40]);

    expect(probabilities[2][0]).toBeGreaterThan(probabilities[1][0]);
    expect(probabilities[1][0]).toBeGreaterThan(probabilities[0][0]);
    expect(probabilities[0][0] + probabilities[1][0] + probabilities[2][0]).toBeCloseTo(1, 5);
  });
});
