Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
test: add test for WrapStream readStop
Browse files Browse the repository at this point in the history
PR-URL: nodejs/node#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>
  • Loading branch information
akaila authored and addaleax committed Oct 26, 2017
1 parent abf81ae commit cf30f57
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 cf30f57

Please sign in to comment.