diff options
author | Luigi Pinca <luigipinca@gmail.com> | 2018-03-27 19:35:03 +0200 |
---|---|---|
committer | Beth Griggs <Bethany.Griggs@uk.ibm.com> | 2018-12-04 15:34:45 +0000 |
commit | a62df1b379082465389e20af9a757d5edc7cc84f (patch) | |
tree | 9aafb84f2b3bd2a517f30f6a2e2c9cc699d6e981 | |
parent | 8a0ecf4360784e10f556518151bcbfbd605bf99e (diff) | |
download | node-new-a62df1b379082465389e20af9a757d5edc7cc84f.tar.gz |
test: refactor test-net-dns-error
- Use `common.mustCall()` and `common.mustNotCall()`.
- Use ternary operator.
PR-URL: https://github.com/nodejs/node/pull/19640
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r-- | test/parallel/test-net-dns-error.js | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/test/parallel/test-net-dns-error.js b/test/parallel/test-net-dns-error.js index a5ae415592..0d943bf6cd 100644 --- a/test/parallel/test-net-dns-error.js +++ b/test/parallel/test-net-dns-error.js @@ -21,27 +21,20 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); +const assert = require('assert'); const net = require('net'); const host = '*'.repeat(256); +const errCode = common.isOpenBSD ? 'EAI_FAIL' : 'ENOTFOUND'; -let errCode = 'ENOTFOUND'; -if (common.isOpenBSD) - errCode = 'EAI_FAIL'; - -function do_not_call() { - throw new Error('This function should not have been called.'); -} - -const socket = net.connect(42, host, do_not_call); +const socket = net.connect(42, host, common.mustNotCall()); socket.on('error', common.mustCall(function(err) { assert.strictEqual(err.code, errCode); })); -socket.on('lookup', function(err, ip, type) { +socket.on('lookup', common.mustCall(function(err, ip, type) { assert(err instanceof Error); assert.strictEqual(err.code, errCode); assert.strictEqual(ip, undefined); assert.strictEqual(type, undefined); -}); +})); |