From dacb6df871500e0547c6c3db2fec5f00dbfc6bb4 Mon Sep 17 00:00:00 2001 From: Jannis Braun <151788261+TheZwiss@users.noreply.github.com> Date: Tue, 28 Apr 2026 14:23:54 +0200 Subject: [PATCH] test(sounds): tighten encodeStreamWatch round-trip assertion to verify Uint8Array contract --- packages/web/src/utils/streamWatchProtocol.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/web/src/utils/streamWatchProtocol.test.ts b/packages/web/src/utils/streamWatchProtocol.test.ts index 7f3a25fe..19074092 100644 --- a/packages/web/src/utils/streamWatchProtocol.test.ts +++ b/packages/web/src/utils/streamWatchProtocol.test.ts @@ -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); });