From 919625bd6a9e8929d1bdf01cf528c313406bc5d9 Mon Sep 17 00:00:00 2001 From: Shilo Mangam Date: Wed, 6 Dec 2017 20:36:28 +0200 Subject: [PATCH] test: use Countdown in test-http-set-cookies PR-URL: https://github.com/nodejs/node/pull/17504 Reviewed-By: Anatoli Papirovski Reviewed-By: Luigi Pinca Reviewed-By: Jon Moss --- test/parallel/test-http-set-cookies.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-http-set-cookies.js b/test/parallel/test-http-set-cookies.js index 44a5f47bbb3d03..c307bda73a3515 100644 --- a/test/parallel/test-http-set-cookies.js +++ b/test/parallel/test-http-set-cookies.js @@ -23,9 +23,9 @@ require('../common'); const assert = require('assert'); const http = require('http'); +const Countdown = require('../common/countdown'); -let nresponses = 0; - +const countdown = new Countdown(2, () => server.close()); const server = http.createServer(function(req, res) { if (req.url === '/one') { res.writeHead(200, [['set-cookie', 'A'], @@ -55,9 +55,7 @@ server.on('listening', function() { }); res.on('end', function() { - if (++nresponses === 2) { - server.close(); - } + countdown.dec(); }); }); @@ -72,14 +70,8 @@ server.on('listening', function() { }); res.on('end', function() { - if (++nresponses === 2) { - server.close(); - } + countdown.dec(); }); }); }); - -process.on('exit', function() { - assert.strictEqual(2, nresponses); -});