import { expect, test } from 'bun:test'; import { obsAuthentication } from './obs'; import { parseTosu } from './tosu'; test('OBS authentication matches the protocol documentation example', () => { expect( obsAuthentication( 'supersecretpassword', 'lM1GncleQOaCu9lT1yeUZhFYnqhsLLP1G5lAGo3ixaI=', '+IxH4CnCiqpX1rM9scsNynZzbOe4KhDeYcTNS3PDaeY=' ) ).toBe('1Ct943GAT+6YQUUX47Ia/ncufilbe6+oD6lY+5kaCu4='); }); test('tosu tourney frames become per-player scores with map progress', () => { const frame = parseTosu({ beatmap: { id: 75, time: { live: 30_000, firstObject: 10_000, lastObject: 50_000 } }, tourney: { ipcState: 3, team: { left: 'Alpha ', right: 'Beta' }, clients: [ { user: { id: 2, name: 'peppy' }, play: { score: 123_456, accuracy: 98.5, failed: false, combo: { current: 321 } } }, { user: { id: 0, name: '' }, play: { score: 0 } } ] } }); expect(frame).toEqual({ ipcState: 3, beatmapId: 75, progress: 0.5, teams: { left: 'Alpha', right: 'Beta' }, clients: [ { osuId: 2, name: 'peppy', score: 123_456, accuracy: 98.5, combo: 321, failed: false } ] }); expect(parseTosu({ beatmap: {} })).toBeNull(); }); test('tosu keeps a named spectator while its profile id is not available', () => { const frame = parseTosu({ tourney: { clients: [ { user: { id: 0, name: '' }, play: { playerName: 'Ocean Player0', score: 123, accuracy: 98, combo: { current: 5 } } }, { user: { id: 0, name: '' }, play: { score: 0 } } ] } }); expect(frame?.clients).toEqual([ { osuId: 0, name: 'Ocean Player0', score: 123, accuracy: 98, combo: 5, failed: false } ]); });