From b4da30f26cf4ca4623f44d221bec2310841f0183 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 | 2 +- test/parallel/test-domain.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-domain-crypto.js b/test/parallel/test-domain-crypto.js index acc90a4a4868cf..d0bdbf4720b913 100644 --- a/test/parallel/test-domain-crypto.js +++ b/test/parallel/test-domain-crypto.js @@ -37,9 +37,9 @@ 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()); const buf = Buffer.alloc(8); crypto.randomFillSync(buf); crypto.pseudoRandomBytes(8); -crypto.pseudoRandomBytes(8, common.noop); -crypto.pbkdf2('password', 'salt', 8, 8, 'sha1', 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 888b452cb998b5..fe7247b2a92c95 100644 --- a/test/parallel/test-domain-timers.js +++ b/test/parallel/test-domain-timers.js @@ -51,4 +51,4 @@ immediated.run(function() { }); }); -const 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 1b6e1c7bbf4d02..6cef4e52936c04 100644 --- a/test/parallel/test-domain.js +++ b/test/parallel/test-domain.js @@ -22,7 +22,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'); @@ -259,7 +259,7 @@ const 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() {