A table's options and its size are read one way, in spec.ts, by the server, the tally and the replay; a game may seat fewer for some options
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
This commit is contained in:
1 parent
faa2845e70
commit
6133a2469a
7 files changed
+64
-23
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { cleanOptions, tableSize, type TableOption } from './spec';
|
||||
|
||||
const options: TableOption[] = [
|
||||
{ key: 'length', label: 'Length', choices: [{ value: 'short', label: 'Short' }, { value: 'long', label: 'Long' }], default: 'short' }
|
||||
];
|
||||
|
||||
describe('table options', () => {
|
||||
it('keeps only declared options and offered choices, the rest at their defaults', () => {
|
||||
expect(cleanOptions({ options }, { length: 'long', colour: 'red' })).toEqual({ length: 'long' });
|
||||
expect(cleanOptions({ options }, { length: 'endless' })).toEqual({ length: 'short' });
|
||||
expect(cleanOptions({ options }, null)).toEqual({ length: 'short' });
|
||||
});
|
||||
|
||||
it('seats as many as the options allow, never more than the seats there are', () => {
|
||||
const seatIds = ['A', 'B', 'C', 'D'];
|
||||
expect(tableSize({ seatIds, options })).toBe(4);
|
||||
const seatsFor = (o: Record<string, string>) => (o.length === 'short' ? 2 : 9);
|
||||
expect(tableSize({ seatIds, options, seatsFor }, { length: 'short' })).toBe(2);
|
||||
expect(tableSize({ seatIds, options, seatsFor }, { length: 'long' })).toBe(4);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user