Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: stream readable readableListening internal state #9864

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions test/parallel/test-stream-readableListening-state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

const common = require('../common');
const assert = require('assert');
const stream = require('stream');

const r = new stream.Readable({
read: () => {}
});

// readableListening state should start in `false`.
assert.strictEqual(r._readableState.readableListening, false);

r.on('readable', common.mustCall(() => {
// Inside the readable event this state should be true.
assert.strictEqual(r._readableState.readableListening, true);
}));

r.push(Buffer.from('Testing readableListening state'));

const r2 = new stream.Readable({
read: () => {}
});

// readableListening state should start in `false`.
assert.strictEqual(r2._readableState.readableListening, false);

r2.on('data', common.mustCall((chunk) => {
// readableListening should be false because we don't have
// a `readable` listener
assert.strictEqual(r2._readableState.readableListening, false);
}));

r2.push(Buffer.from('Testing readableListening state'));