Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f3efaee

Browse filesBrowse files
hiroppyevanlucas
authored andcommitted
test: increase coverage for stream's duplex
Make use of Arrow function. Add a small test and this file's coverage is 100%. https://github.com/nodejs/node/blob/a647d82f83ad5ddad5db7be2cc24c3d686121792/lib/_stream_duplex.js#L25 Coverage: https://coverage.nodejs.org/coverage-067be658f966dafe/root/_stream_duplex.js.html PR-URL: #10963 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent b5e8413 commit f3efaee
Copy full SHA for f3efaee

File tree

Expand file treeCollapse file tree

1 file changed

+5
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-4
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-stream-duplex.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-duplex.js
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,28 @@ const Duplex = require('stream').Transform;
55

66
const stream = new Duplex({ objectMode: true });
77

8+
assert(Duplex() instanceof Duplex);
89
assert(stream._readableState.objectMode);
910
assert(stream._writableState.objectMode);
1011

1112
let written;
1213
let read;
1314

14-
stream._write = function(obj, _, cb) {
15+
stream._write = (obj, _, cb) => {
1516
written = obj;
1617
cb();
1718
};
1819

19-
stream._read = function() {};
20+
stream._read = () => {};
2021

21-
stream.on('data', function(obj) {
22+
stream.on('data', (obj) => {
2223
read = obj;
2324
});
2425

2526
stream.push({ val: 1 });
2627
stream.end({ val: 2 });
2728

28-
process.on('exit', function() {
29+
process.on('exit', () => {
2930
assert.strictEqual(read.val, 1);
3031
assert.strictEqual(written.val, 2);
3132
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.