Files
esports/streamer/tourney.test.ts

24 lines
849 B
TypeScript

import { expect, test } from 'bun:test';
import { findRoom } from './tourney';
const header =
'level\tpage_num\tblock_num\tpar_num\tline_num\tword_num\tleft\ttop\twidth\theight\tconf\ttext';
const word = (line: number, index: number, left: number, text: string) =>
`5\t1\t1\t1\t${line}\t${index}\t${left}\t${line * 30}\t${text.length * 8}\t16\t90\t${text}`;
test('selects the named tourney room, not the first room in the panel', () => {
const tsv = [
header,
word(1, 1, 20, 'VASH:'),
word(1, 2, 85, '(Other)'),
word(1, 3, 160, 'vs'),
word(1, 4, 190, '(Player)'),
word(2, 1, 20, 'VASH:'),
word(2, 2, 85, '(Alpha)'),
word(2, 3, 160, 'vs'),
word(2, 4, 190, '(Beta)')
].join('\n');
expect(findRoom(tsv, 'VASH: (Alpha) vs (Beta)')).toEqual({ x: 129, y: 68 });
expect(findRoom(tsv, 'VASH: (Missing) vs (Beta)')).toBeNull();
});