Files
esports/streamer/obs.test.ts

39 lines
1.1 KiB
TypeScript

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,
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,
clients: [
{ osuId: 2, name: 'peppy', score: 123_456, accuracy: 98.5, combo: 321, failed: false }
]
});
expect(parseTosu({ beatmap: {} })).toBeNull();
});