test(sounds): tighten encodeStreamWatch round-trip assertion to verify Uint8Array contract

This commit is contained in:
Jannis Braun
2026-04-28 14:23:54 +02:00
parent 6a4eac13a3
commit dacb6df871
@@ -9,8 +9,9 @@ describe('streamWatchProtocol', () => {
it('round-trips an encoded payload', () => {
const payload = { type: 'stream_watch' as const, target: 'user-1', watching: true };
const encoded = encodeStreamWatch(payload);
expect(encoded).toBeDefined();
expect(encoded.length).toBeGreaterThan(0);
// Verify contract: TextEncoder.encode always returns Uint8Array with buffer + byteLength
expect(encoded.buffer).toBeDefined();
expect(encoded.byteLength).toBeGreaterThan(0);
const parsed = parseStreamWatch(encoded);
expect(parsed).toEqual(payload);
});