# Hold'em dealer tests Unit tests for the money logic behind `/Casino/TexasHoldem` — the betting engine, the side-pot calculator, the split calculator and the table state. ```bash node --test tests/holdem/*.test.js ``` No install step, no `package.json`, no dependencies. The browser modules are plain script-tag files that each end with a `module.exports` guard, so Node can require them as-is; `load.js` puts them on `globalThis` under the same names they use to find each other in the page, in the load order from `TexasHoldem.cshtml`. ## What's covered | File | Covers | | --- | --- | | `potCalculator.test.js` | Main and side pots, dead money, uncalled bets, odd-cent distribution | | `betting.test.js` | Blinds, street completion, raises reopening the action, all-in run-outs | | `state.test.js` | Button rotation, which seats post blinds, session standings | | `splitCalculator.test.js` | Chopped pots, odd chips, unmakeable denominations | | `invariants.test.js` | 1000 randomised hands per property (see below) | ## Why the randomised suite exists Every correctness bug found in this tool so far has been shape-dependent: blinds posted to empty chairs, the button skipping past players, heads-up acting out of order, an overbet announced as a side pot. None of them show up on a full six-handed table with equal stacks, which is the table anyone writes a fixed example for. `invariants.test.js` deals a thousand hands across random seat counts, random empty chairs, random stack depths and random dealer input, and checks the things a dealer would notice being wrong: - chips are never created or destroyed during play - the pot breakdown plus the uncalled returns always equal the money that went in - paying the pot out settles it to the cent - once uncalled chips are handed back, nobody is still betting above the whole table - the button and both blinds always land on players who are actually in the hand The generator is seeded, so a failure reproduces from the seed printed in the message rather than being a flake to re-run.