0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-net-end-close.js
Sam Roberts 84f3b8f09f doc: document and test that methods return this
Also, add tests to ensure they will always return this, and to confirm
they return this when these doc changes are back-ported to earlier
release lines.

PR-URL: https://github.com/nodejs/node/pull/13531
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-06-14 13:12:21 -07:00

27 lines
559 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const net = require('net');
const uv = process.binding('uv');
const s = new net.Socket({
handle: {
readStart: function() {
process.nextTick(() => this.onread(uv.UV_EOF, null));
},
close: (cb) => process.nextTick(cb)
},
writable: false
});
assert.strictEqual(s, s.resume());
const events = [];
s.on('end', () => events.push('end'));
s.on('close', () => events.push('close'));
process.on('exit', () => {
assert.deepStrictEqual(events, [ 'end', 'close' ]);
});