Files
orca/src/shared/file-content/node-readable-text.test.ts
T
OrcaWinandOrcaWin c0d3d2e0db test: remove 13 low-value suites and redundant cases (#40138)
* Remove low-value file, runtime and chat test cases

* test: remove low-value shared contract and timing suites

* test: remove leaking browser IPC mock suite

* test: isolate legacy relay bridge transport fixture

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-11-08 21:51:31 -08:00

29 lines
836 B
TypeScript

import { describe, expect, it } from 'vitest'
import {
NodeReadableTextTooLargeError,
readNodeReadableTextWithinLimit
} from './node-readable-text'
async function* chunks(values: unknown[]): AsyncGenerator<unknown> {
yield* values
}
describe('readNodeReadableTextWithinLimit', () => {
it('preserves accepted UTF-8 bytes split across chunks', async () => {
const encoded = Buffer.from('hello 🌍')
await expect(
readNodeReadableTextWithinLimit(
chunks([encoded.subarray(0, 8), encoded.subarray(8)]),
encoded.byteLength
)
).resolves.toBe('hello 🌍')
})
it('rejects before retaining input beyond the byte limit', async () => {
await expect(readNodeReadableTextWithinLimit(chunks(['1234', '5']), 4)).rejects.toEqual(
new NodeReadableTextTooLargeError(5, 4)
)
})
})