MCPcopy Index your code
hub / github.com/nodejs/node / testAsyncValidation

Function testAsyncValidation

test/parallel/test-stream-iter-validation.js:241–312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

239const consume = (transform) => bytes(pull(from('test'), transform));
240
241async function testAsyncValidation() {
242 // pipeTo signal
243 await assert.rejects(
244 () => pipeTo(from('a'), { write() {} }, { signal: 'bad' }),
245 { code: 'ERR_INVALID_ARG_TYPE' },
246 );
247
248 // Async consumer options
249 await assert.rejects(
250 () => bytes(from('a'), 42), { code: 'ERR_INVALID_ARG_TYPE' });
251 await assert.rejects(
252 () => bytes(from('a'), { signal: 'bad' }), { code: 'ERR_INVALID_ARG_TYPE' });
253 await assert.rejects(
254 () => bytes(from('a'), { limit: 'bad' }), { code: 'ERR_INVALID_ARG_TYPE' });
255 await assert.rejects(
256 () => bytes(from('a'), { limit: -1 }), { code: 'ERR_OUT_OF_RANGE' });
257 await assert.rejects(
258 () => text(from('a'), { encoding: 42 }), { code: 'ERR_INVALID_ARG_TYPE' });
259 await assert.rejects(
260 () => text(from('a'), { encoding: 'not-a-real-encoding' }),
261 { code: 'ERR_INVALID_ARG_VALUE' });
262 await assert.rejects(
263 () => arrayBuffer(from('a'), { limit: 'bad' }),
264 { code: 'ERR_INVALID_ARG_TYPE' });
265 await assert.rejects(
266 () => array(from('a'), { limit: -1 }), { code: 'ERR_OUT_OF_RANGE' });
267
268 const TYPE = { code: 'ERR_INVALID_ARG_TYPE' };
269 const RANGE = { code: 'ERR_OUT_OF_RANGE' };
270 const BROTLI = { code: 'ERR_BROTLI_INVALID_PARAM' };
271 const ZSTD = { code: 'ERR_ZSTD_INVALID_PARAM' };
272
273 // ChunkSize
274 await assert.rejects(consume(compressGzip({ chunkSize: 'bad' })), TYPE);
275 await assert.rejects(consume(compressGzip({ chunkSize: 0 })), RANGE);
276 await assert.rejects(consume(compressGzip({ chunkSize: 10 })), RANGE);
277
278 // WindowBits
279 await assert.rejects(consume(compressGzip({ windowBits: 'bad' })), TYPE);
280 await assert.rejects(consume(compressGzip({ windowBits: 100 })), RANGE);
281
282 // Level
283 await assert.rejects(consume(compressGzip({ level: 'bad' })), TYPE);
284 await assert.rejects(consume(compressGzip({ level: 100 })), RANGE);
285
286 // MemLevel
287 await assert.rejects(consume(compressGzip({ memLevel: 'bad' })), TYPE);
288 await assert.rejects(consume(compressGzip({ memLevel: 100 })), RANGE);
289
290 // Strategy
291 await assert.rejects(consume(compressGzip({ strategy: 'bad' })), TYPE);
292 await assert.rejects(consume(compressGzip({ strategy: 100 })), RANGE);
293
294 // Dictionary
295 await assert.rejects(consume(compressGzip({ dictionary: 42 })), TYPE);
296 await assert.rejects(consume(compressGzip({ dictionary: 'bad' })), TYPE);
297
298 // Brotli params

Callers 1

Calls 10

pipeToFunction · 0.85
compressGzipFunction · 0.85
compressBrotliFunction · 0.85
compressZstdFunction · 0.85
consumeFunction · 0.70
fromFunction · 0.50
bytesFunction · 0.50
textFunction · 0.50
arrayBufferFunction · 0.50
arrayFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…