mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
9702ac5088
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>
43 lines
817 B
JavaScript
43 lines
817 B
JavaScript
// 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);
|