Skip to content

Commit a62df1b

Browse files
lpincaBethGriggs
authored andcommitted
test: refactor test-net-dns-error
- Use `common.mustCall()` and `common.mustNotCall()`. - Use ternary operator. PR-URL: #19640 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8a0ecf4 commit a62df1b

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

test/parallel/test-net-dns-error.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,20 @@
2121

2222
'use strict';
2323
const common = require('../common');
24-
const assert = require('assert');
2524

25+
const assert = require('assert');
2626
const net = require('net');
2727

2828
const host = '*'.repeat(256);
29+
const errCode = common.isOpenBSD ? 'EAI_FAIL' : 'ENOTFOUND';
2930

30-
let errCode = 'ENOTFOUND';
31-
if (common.isOpenBSD)
32-
errCode = 'EAI_FAIL';
33-
34-
function do_not_call() {
35-
throw new Error('This function should not have been called.');
36-
}
37-
38-
const socket = net.connect(42, host, do_not_call);
31+
const socket = net.connect(42, host, common.mustNotCall());
3932
socket.on('error', common.mustCall(function(err) {
4033
assert.strictEqual(err.code, errCode);
4134
}));
42-
socket.on('lookup', function(err, ip, type) {
35+
socket.on('lookup', common.mustCall(function(err, ip, type) {
4336
assert(err instanceof Error);
4437
assert.strictEqual(err.code, errCode);
4538
assert.strictEqual(ip, undefined);
4639
assert.strictEqual(type, undefined);
47-
});
40+
}));

0 commit comments

Comments
 (0)