testsAndMisc/poker-stakes/src/stakes/settlement.test.ts
Krzysztof kuhy Rudnicki 72a5e28456 Track poker-stakes so the file-length cap can reach it
The directory has existed on disk with 58 untracked files, four of them over
the 250-line cap. An untracked file is invisible to every pre-commit hook, so
those violations could not be fixed or gated while it stayed that way -- and
its CI workflow was untracked too, so nothing ran against it.

Landed with its already-written evidence artifact and a contract, since this
crosses the 4-file threshold.

Verified before staging: 58 plain text source/config files, no binaries, no
node_modules, no build output. npm run check passes -- typecheck, eslint
--max-warnings 0, and 220 tests at 100% statements/branches/functions/lines.

Splitting its four oversized files is deliberately a separate commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 15:19:07 +02:00

35 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import type { SessionOutcome } from '../engine/session'
import { settleSession } from './settlement'
import type { BuyIn } from './types'
const buyIn: BuyIn = { taskTypeId: 'pushups', chips: 100 }
describe('settleSession', () => {
const cases: { name: string; outcome: SessionOutcome; owedUnits: number }[] = [
{ name: 'doubled up', outcome: { reason: 'cashOut', finalChips: 200 }, owedUnits: 0 },
{ name: 'partial win', outcome: { reason: 'cashOut', finalChips: 150 }, owedUnits: 50 },
{ name: 'break-even', outcome: { reason: 'cashOut', finalChips: 100 }, owedUnits: 100 },
{ name: 'partial loss', outcome: { reason: 'cashOut', finalChips: 50 }, owedUnits: 150 },
{ name: 'bust to zero', outcome: { reason: 'bust', finalChips: 0 }, owedUnits: 200 },
]
it.each(cases)('$name: owes $owedUnits units', ({ outcome, owedUnits }) => {
const debt = settleSession(buyIn, outcome, 'debt-1', 12345)
expect(debt.owedUnits).toBe(owedUnits)
})
it('carries the task type, reason, id, and settledAt through unchanged', () => {
const outcome: SessionOutcome = { reason: 'bust', finalChips: 0 }
const debt = settleSession(buyIn, outcome, 'debt-42', 999)
expect(debt).toEqual({
id: 'debt-42',
taskTypeId: 'pushups',
owedUnits: 200,
reason: 'bust',
settledAt: 999,
paidUnits: 0,
})
})
})