import { describe, expect, it } from "vitest"; import { describeHandStrength } from "@/lib/minigames/poker/handHint"; import type { Card, Rank, Suit } from "@/lib/minigames/poker"; const c = (rank: Rank, suit: Suit): Card => ({ rank, suit }); describe("poker hand strength hints", () => { it("describes a preflop pair", () => { expect(describeHandStrength([c(13, "s"), c(13, "h")], [])).toEqual({ label: "Pair of Kings", bestCardKeys: ["13-s", "13-h"], }); }); it("describes a preflop high card", () => { expect(describeHandStrength([c(14, "s"), c(9, "h")], [])).toEqual({ label: "High card Ace", bestCardKeys: ["14-s"], }); }); it("describes flop two pair and returns the exact best cards", () => { const hint = describeHandStrength([c(13, "s"), c(9, "h")], [c(13, "d"), c(9, "c"), c(2, "s")]); expect(hint?.label).toBe("Two pair, Kings and Nines"); expect(new Set(hint?.bestCardKeys)).toEqual(new Set(["13-s", "9-h", "13-d", "9-c", "2-s"])); }); it("describes a river straight that uses one hole card", () => { const hint = describeHandStrength( [c(6, "s"), c(14, "h")], [c(2, "c"), c(3, "d"), c(4, "h"), c(5, "s"), c(13, "c")], ); expect(hint?.label).toBe("Straight, Six high"); expect(new Set(hint?.bestCardKeys)).toEqual(new Set(["6-s", "2-c", "3-d", "4-h", "5-s"])); }); it("labels a wheel straight as five high", () => { expect( describeHandStrength( [c(14, "s"), c(13, "h")], [c(2, "c"), c(3, "d"), c(4, "h"), c(5, "s"), c(9, "c")], )?.label, ).toBe("Straight, Five high"); }); });