Skip to content

Commit

Permalink
refac: refactor test-http-response-multiheaders to use countdown
Browse files Browse the repository at this point in the history
  • Loading branch information
hmammedzadeh committed Dec 3, 2017
1 parent e9e9863 commit 8365fc7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/parallel/test-http-response-multiheaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const common = require('../common');
const http = require('http');
const assert = require('assert');
const Countdown = require('../common/countdown');

// Test that certain response header fields do not repeat.
// 'content-length' should also be in this list but it is
Expand Down Expand Up @@ -47,7 +48,7 @@ const server = http.createServer(function(req, res) {
});

server.listen(0, common.mustCall(function() {
let count = 0;
const countdown = new Countdown(2, () => server.close());
for (let n = 1; n <= 2; n++) {
// this runs twice, the first time, the server will use
// setHeader, the second time it uses writeHead. The
Expand All @@ -58,7 +59,7 @@ server.listen(0, common.mustCall(function() {
http.get(
{ port: this.address().port, headers: { 'x-num': n } },
common.mustCall(function(res) {
if (++count === 2) server.close();
countdown.dec();
for (const name of norepeat) {
assert.strictEqual(res.headers[name], 'A');
}
Expand Down

0 comments on commit 8365fc7

Please sign in to comment.