1// Flags: --no-warnings --expose-internals 2'use strict'; 3 4require('../common'); 5 6const { 7 ByteLengthQueuingStrategy, 8 CountQueuingStrategy, 9} = require('stream/web'); 10 11const { 12 inspect, 13} = require('util'); 14 15const { 16 isPromisePending, 17} = require('internal/webstreams/util'); 18 19const assert = require('assert'); 20 21assert(!isPromisePending({})); 22assert(!isPromisePending(Promise.resolve())); 23assert(isPromisePending(new Promise(() => {}))); 24 25// Brand checking works 26assert.throws(() => { 27 Reflect.get(ByteLengthQueuingStrategy.prototype, 'highWaterMark', {}); 28}, { 29 code: 'ERR_INVALID_THIS' 30}); 31 32assert.throws(() => { 33 Reflect.get(ByteLengthQueuingStrategy.prototype, 'size', {}); 34}, { 35 code: 'ERR_INVALID_THIS' 36}); 37 38assert.throws(() => { 39 Reflect.get(CountQueuingStrategy.prototype, 'highWaterMark', {}); 40}, { 41 code: 'ERR_INVALID_THIS' 42}); 43 44assert.throws(() => { 45 Reflect.get(CountQueuingStrategy.prototype, 'size', {}); 46}, { 47 code: 'ERR_INVALID_THIS' 48}); 49 50// Custom Inspect Works 51 52{ 53 const strategy = new CountQueuingStrategy({ highWaterMark: 1 }); 54 55 assert.strictEqual( 56 inspect(strategy, { depth: null }), 57 'CountQueuingStrategy { highWaterMark: 1 }'); 58 59 assert.strictEqual( 60 inspect(strategy), 61 'CountQueuingStrategy { highWaterMark: 1 }'); 62 63 assert.strictEqual( 64 inspect(strategy, { depth: 0 }), 65 'CountQueuingStrategy [Object]'); 66 67 assert.strictEqual( 68 inspect(new ByteLengthQueuingStrategy({ highWaterMark: 1 })), 69 'ByteLengthQueuingStrategy { highWaterMark: 1 }'); 70} 71