test: add test for WrapStream readStop
PR-URL: https://github.com/nodejs/node/pull/16356 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
This commit is contained in:
parent
f0b871bada
commit
9702ac5088
42
test/parallel/test-wrap-js-stream-read-stop.js
Normal file
42
test/parallel/test-wrap-js-stream-read-stop.js
Normal file
@ -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);
|
Loading…
x
Reference in New Issue
Block a user