diff --git a/test/parallel/test-wrap-js-stream-read-stop.js b/test/parallel/test-wrap-js-stream-read-stop.js new file mode 100644 index 00000000000000..f51b3ecf524e30 --- /dev/null +++ b/test/parallel/test-wrap-js-stream-read-stop.js @@ -0,0 +1,42 @@ +// Flags: --expose-internals +'use strict'; + +require('../common'); +const assert = require('assert'); +const WrapStream = require('internal/wrap_js_stream'); +const Stream = require('stream'); + +class FakeStream extends Stream { + constructor() { + super(); + this._paused = false; + } + + pause() { + this._paused = true; + } + + resume() { + this._paused = false; + } + + isPaused() { + return this._paused; + } +} + +const fakeStreamObj = new FakeStream(); +const wrappedStream = new WrapStream(fakeStreamObj); + +// Resume by wrapped stream upon construction +assert.strictEqual(fakeStreamObj.isPaused(), false); + +fakeStreamObj.pause(); + +assert.strictEqual(fakeStreamObj.isPaused(), true); + +fakeStreamObj.resume(); + +assert.strictEqual(wrappedStream.readStop(), 0); + +assert.strictEqual(fakeStreamObj.isPaused(), true);