import { describe, it, expect } from 'vitest' import { decodeShellPayload, shellPayloadByteLength } from '../../src/utils/shellData' describe('decodeShellPayload', () => { it('decodes number arrays as UTF-8 bytes (not Array.join)', () => { // ESC [ ? 2 0 0 4 l → bracketed paste off const bytes = [27, 91, 63, 50, 48, 48, 52, 108] const text = decodeShellPayload(bytes) expect(text).toBe('\x1b[?2004l') expect(text).not.toContain(',') }) it('decodes Buffer-like objects', () => { const payload = { type: 'Buffer', data: [114, 111, 111, 116] } // "root" expect(decodeShellPayload(payload)).toBe('root') }) it('passes through strings', () => { expect(decodeShellPayload('hello')).toBe('hello') }) it('decodes Uint8Array', () => { expect(decodeShellPayload(new Uint8Array([65, 66, 67]))).toBe('ABC') }) }) describe('shellPayloadByteLength', () => { it('counts array length', () => { expect(shellPayloadByteLength([1, 2, 3])).toBe(3) }) })