From eba9add48eabb9914596fc4b6b1cc522517722ae Mon Sep 17 00:00:00 2001 From: BethGriggs Date: Thu, 29 Dec 2016 10:28:10 +0000 Subject: [PATCH] test: refactor test-timer-close Refactor and simplify parallel/test-timer-close.js. Add comment to describe the test case. PR-URL: https://github.com/nodejs/node/pull/10517 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno Reviewed-By: Jeremiah Senkpiel Reviewed-By: James M Snell Reviewed-By: Gibson Fahnestock --- test/parallel/test-timer-close.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-timer-close.js b/test/parallel/test-timer-close.js index 28217ce0397b0f..aae93f25c55ec0 100644 --- a/test/parallel/test-timer-close.js +++ b/test/parallel/test-timer-close.js @@ -1,16 +1,11 @@ 'use strict'; -require('../common'); -const assert = require('assert'); +const common = require('../common'); -var t = new (process.binding('timer_wrap').Timer)(); -var called = 0; -function onclose() { - called++; -} +// Make sure handle._handle.close(callback) is idempotent by closing a timer +// twice. The first function should be called, the second one should not. -t.close(onclose); -t.close(onclose); +const Timer = process.binding('timer_wrap').Timer; +const t = new Timer(); -process.on('exit', function() { - assert.equal(1, called); -}); +t.close(common.mustCall(function() {})); +t.close(() => common.fail('This should never be called'));