Skip to content

Commit

Permalink
test: add test for WrapStream readStop
Browse files Browse the repository at this point in the history
PR-URL: #16356
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
  • Loading branch information
akaila authored and gibfahn committed Nov 14, 2017
1 parent 9df1e8f commit 47b1c3b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/parallel/test-wrap-js-stream-read-stop.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 47b1c3b

Please sign in to comment.