-
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
- Loading branch information
1 parent
f0b871b
commit 9702ac5
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); |