not-tonight/tests/lipRead.test.ts

39 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { lipReadLine } from '../src/rules/lipRead';
describe('lipReadLine', () => {
it('is deterministic — re-asking does not reroll reality', () => {
const line = 'mate im on the list i promise you im on the list';
expect(lipReadLine(line, 'p1')).toBe(lipReadLine(line, 'p1'));
});
it('different patrons hear the room differently', () => {
const line = 'im on the list i swear on my nan';
const guesses = new Set(['p1', 'p2', 'p3', 'p4', 'p5'].map((s) => lipReadLine(line, s)));
expect(guesses.size).toBeGreaterThan(1);
});
it('every token is a bracketed uppercase guess', () => {
const out = lipReadLine('mate the owner literally invited me', 'p9');
for (const tok of out.split(' ')) {
expect(tok.startsWith('[')).toBe(true);
expect(tok.endsWith(']')).toBe(true);
expect(tok).toBe(tok.toUpperCase());
}
});
it('shows real uncertainty across a long line — not a clean transcript', () => {
const out = lipReadLine(
'listen i know the promoter and the promoter knows the owner and honestly the whole situation is very much under control',
'p2',
);
expect(out).toContain('?');
});
it('never emits an empty guess', () => {
expect(lipReadLine('', 'p1')).toBe('[???]');
expect(lipReadLine('...', 'p1')).toBe('[???]');
expect(lipReadLine('*points*', 'p1').length).toBeGreaterThan(0);
});
});