Skip to content
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
test: improve test-net-socket-timeout
* Check for custom Node.js code rather than constructor in
  assert.throws().
* Use arrow functions consistently.
  • Loading branch information
Trott committed Dec 5, 2018
commit 7669ddc952ed17b6fdeb5d337068cb6652f88ff0
14 changes: 7 additions & 7 deletions test/parallel/test-net-socket-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@ const validDelays = [0, 0.001, 1, 1e6];


for (let i = 0; i < nonNumericDelays.length; i++) {
assert.throws(function() {
assert.throws(() => {
s.setTimeout(nonNumericDelays[i], () => {});
}, TypeError, nonNumericDelays[i]);
}, { code: 'ERR_INVALID_ARG_TYPE' }, nonNumericDelays[i]);
}

for (let i = 0; i < badRangeDelays.length; i++) {
assert.throws(function() {
assert.throws(() => {
s.setTimeout(badRangeDelays[i], () => {});
}, RangeError, badRangeDelays[i]);
}, { code: 'ERR_OUT_OF_RANGE' }, badRangeDelays[i]);
}

for (let i = 0; i < validDelays.length; i++) {
s.setTimeout(validDelays[i], () => {});
}

const server = net.Server();
server.listen(0, common.mustCall(function() {
const socket = net.createConnection(this.address().port);
socket.setTimeout(1, common.mustCall(function() {
server.listen(0, common.mustCall(() => {
const socket = net.createConnection(server.address().port);
socket.setTimeout(1, common.mustCall(() => {
socket.destroy();
server.close();
}));
Expand Down