Files
waving-hands/src/lib/game/tally.test.ts
T
Eric WagonerandClaude Fable 5.1 7c60d19ad3 The tally: what the ledgers add up to, in the about panel
Ported from the game kit (7aa0553). GET /api/tally scans the ledgers,
replays each duel, and returns the counts, cached a minute; the duel's
own lines come from tallyOf on the final state (wins by slaying or by
surrender, draws, wizards slain and yielded, stopped moments). The hall
fetches it when the about panel opens.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0141G6xqLeNRYEtviLWSB5Up
2026-09-23 18:36:32 -04:00

17 lines
632 B
TypeScript

import { describe, expect, it } from 'vitest';
import { createGame } from './state';
import { play } from './test-helpers';
import { tallyOf } from './tally';
describe('the tally of a finished duel', () => {
it('counts nothing for a duel still in play', () => {
expect(tallyOf(createGame({ A: 'Ann', B: 'Bo' }, 1))).toEqual({});
});
it('counts a surrender as a win by surrender', () => {
const s = play(createGame({ A: 'Ann', B: 'Bo' }, 1), { left: 'P', right: 'P' });
expect(s.over?.winner).toBe('B');
expect(tallyOf(s)).toEqual({ "duels won by a rival's surrender": 1, 'wizards who yielded, all told': 1 });
});
});