Add server chat tab and show all four players
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseGameChat } from '../../src/lib/game-chat.js';
|
||||
|
||||
describe('game chat', () => {
|
||||
it('extracts say messages and ignores joins', () => {
|
||||
expect(parseGameChat([
|
||||
' 61:19 J;6493949;3;Conda1989',
|
||||
' 63:09 say;4229696;0;alienfr;\x15just noticed i didnt have ANY perks go figure',
|
||||
' 63:22 say;2989140;1;mikakyu;\x15whoopsie'
|
||||
])).toEqual([
|
||||
{ time: '63:09', guid: '4229696', slot: 0, player: 'alienfr', message: 'just noticed i didnt have ANY perks go figure' },
|
||||
{ time: '63:22', guid: '2989140', slot: 1, player: 'mikakyu', message: 'whoopsie' }
|
||||
]);
|
||||
});
|
||||
|
||||
it('preserves semicolons, Unicode, repeated messages and log order across timer resets', () => {
|
||||
const lines = ['120:59 say;abc;2;^2Player;\x15hello; café <b>friends</b>!',
|
||||
'0:01 say;abc;2;Player;hello', '0:01 say;abc;2;Player;hello'];
|
||||
const messages = parseGameChat(lines);
|
||||
expect(messages.map(message => message.time)).toEqual(['120:59', '0:01', '0:01']);
|
||||
expect(messages[0]).toMatchObject({ player: 'Player', message: 'hello; café <b>friends</b>!' });
|
||||
expect(messages).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('ignores malformed, unrelated and empty entries', () => {
|
||||
expect(parseGameChat(['', 'say;123;0;Player;no timestamp', '1:00 say;123;0;Player',
|
||||
'1:00 say;123;bad;Player;hello', '1:00 say;123;0;Player;\x15^7',
|
||||
'1:00 InitGame: say;123;0;Player;hello', '1:00 sayteam;123;0;Player;hello'])).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user