import { describe, expect, it } from 'vitest'; import { claimMessage, commandMessage, helloMessage, pingMessage } from '$lib/protocol/types'; describe('wire protocol builders', () => { it('builds the hello handshake message', () => { expect(helloMessage()).toEqual({ t: 'hello', v: 1 }); }); it('builds a command message with default empty args', () => { expect(commandMessage('draw')).toEqual({ t: 'cmd', name: 'draw', args: {} }); }); it('builds a command message with args', () => { expect( commandMessage('addCharacter', { id: 'Berserker', edition: 'x' }) ).toEqual({ t: 'cmd', name: 'addCharacter', args: { id: 'Berserker', edition: 'x' } }); }); it('builds claim, ping messages', () => { expect(claimMessage('Berserker')).toEqual({ t: 'claim', characterId: 'Berserker' }); expect(pingMessage()).toEqual({ t: 'ping' }); }); });