From 3bdf7bf9e949ceb6ceceed7715bedff64870e821 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 5 Jun 2017 11:22:26 -0700 Subject: [PATCH] test: refactor domain tests * Check that noop callback is or isn't invoked as appropriate using common.mustCall() and common.mustNotCall() * Fix typo in array literal PR-URL: https://github.com/nodejs/node/pull/13480 Reviewed-By: James M Snell Reviewed-By: Refael Ackermann Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson --- test/parallel/test-domain-crypto.js | 6 +++--- test/parallel/test-domain-timers.js | 4 +--- test/parallel/test-domain.js | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-domain-crypto.js b/test/parallel/test-domain-crypto.js index bc9c4b6d46..7f009b45df 100644 --- a/test/parallel/test-domain-crypto.js +++ b/test/parallel/test-domain-crypto.js @@ -17,7 +17,7 @@ global.domain = require('domain'); // should not throw a 'TypeError: undefined is not a function' exception crypto.randomBytes(8); -crypto.randomBytes(8, common.noop); +crypto.randomBytes(8, common.mustCall()); crypto.pseudoRandomBytes(8); -crypto.pseudoRandomBytes(8, common.noop); -crypto.pbkdf2('password', 'salt', 8, 8, common.noop); +crypto.pseudoRandomBytes(8, common.mustCall()); +crypto.pbkdf2('password', 'salt', 8, 8, 'sha1', common.mustCall()); diff --git a/test/parallel/test-domain-timers.js b/test/parallel/test-domain-timers.js index 7fff546856..bb130ae080 100644 --- a/test/parallel/test-domain-timers.js +++ b/test/parallel/test-domain-timers.js @@ -3,8 +3,6 @@ const common = require('../common'); const domain = require('domain'); const assert = require('assert'); -let timeout; - const timeoutd = domain.create(); timeoutd.on('error', common.mustCall(function(e) { @@ -32,4 +30,4 @@ immediated.run(function() { }); }); -timeout = setTimeout(common.noop, 10 * 1000); +const timeout = setTimeout(common.mustNotCall(), 10 * 1000); diff --git a/test/parallel/test-domain.js b/test/parallel/test-domain.js index f5dc699f25..0233eb88eb 100644 --- a/test/parallel/test-domain.js +++ b/test/parallel/test-domain.js @@ -1,7 +1,7 @@ 'use strict'; // Simple tests of most basic domain functionality. -const common = require('../common'); +require('../common'); const assert = require('assert'); const domain = require('domain'); const events = require('events'); @@ -238,7 +238,7 @@ let fst = fs.createReadStream('stream for nonexistent file'); d.add(fst); expectCaught++; -[42, null, , false, common.noop, 'string'].forEach(function(something) { +[42, null, undefined, false, () => {}, 'string'].forEach(function(something) { const d = new domain.Domain(); d.run(function() { process.nextTick(function() {