import { test } from "node:test"; import assert from "node:assert/strict"; import { normalizeNumbers, numbersIn } from "./numberWords"; const cases: [string, string][] = [ ["eighty five players left", "85 players left"], ["fifteen players left", "15 players left"], ["$2,750 buy in", "$2750 buy in"], ["an opponent at five hundred sixty seven thousand chips", "an opponent at 567000 chips"], ["the average stack is three hundred seventy three thousand, I have two hundred thirty three", "the average stack is 373000, I have 233"], ["a double up would put me in the top twenty", "a double up would put me in the top 20"], ["first place five hundred bucks", "first place 500 bucks"], ["blinds are five ten", "blinds are 5 10"], ["one point five million", "1500000"], ["233k and 10M", "233000 and 10000000"], ["two million three hundred thousand", "2300000"], ["a hundred and five", "105"], ["eighty-five", "85"], ["twenty five hundred", "2500"], ["I have no one to call", "I have no one to call"], ["level 14, blinds 1,500/3,000 ante 3,000", "level 14, blinds 1500/3000 ante 3000"], ["thousand thousand", "1000 1000"], ["a cat", "a cat"], ["the average is four hundred twelve K and I have", "the average is 412000 and I have"], ["sixty k", "60000"], ["a k of spades", "a k of spades"], ["I climbed to seventy second", "I climbed to 72"], ["first place gets the most, third place less", "first place gets the most, third place less"], ["the fifteenth hand", "the 15 hand"], ]; test("normalizeNumbers: spoken and written numbers become plain digits, the rest is kept", () => { for (const [input, want] of cases) assert.equal(normalizeNumbers(input), want, input); }); test("numbersIn: every number, in order", () => { assert.deepEqual(numbersIn("blinds two hundred four hundred, eighty five left"), [200, 400, 85]); assert.deepEqual(numbersIn("nothing here"), []); });