-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for WrapStream readStop
PR-URL: #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
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |