| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,8 +3,7 @@ require('../common'); | |||
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | const http = require('http'); | |
| 5 | 5 | const net = require('net'); | |
| 6 | - | ||
| 7 | - let testsComplete = 0; | ||
| 6 | + const Countdown = require('../common/countdown'); | ||
| 8 | 7 | ||
| 9 | 8 | const testCases = [ | |
| 10 | 9 | { path: '/200', statusMessage: 'OK', | |
@@ -38,6 +37,8 @@ const server = net.createServer(function(connection) { | |||
| 38 | 37 | }); | |
| 39 | 38 | }); | |
| 40 | 39 | ||
| 40 | + const countdown = new Countdown(testCases.length, () => server.close()); | ||
| 41 | + | ||
| 41 | 42 | function runTest(testCaseIndex) { | |
| 42 | 43 | const testCase = testCases[testCaseIndex]; | |
| 43 | 44 | ||
@@ -50,12 +51,9 @@ function runTest(testCaseIndex) { | |||
| 50 | 51 | assert.strictEqual(testCase.statusMessage, response.statusMessage); | |
| 51 | 52 | ||
| 52 | 53 | response.on('end', function() { | |
| 53 | - testsComplete++; | ||
| 54 | - | ||
| 54 | + countdown.dec(); | ||
| 55 | 55 | if (testCaseIndex + 1 < testCases.length) { | |
| 56 | 56 | runTest(testCaseIndex + 1); | |
| 57 | - } else { | ||
| 58 | - server.close(); | ||
| 59 | 57 | } | |
| 60 | 58 | }); | |
| 61 | 59 | ||
@@ -64,7 +62,3 @@ function runTest(testCaseIndex) { | |||
| 64 | 62 | } | |
| 65 | 63 | ||
| 66 | 64 | server.listen(0, function() { runTest(0); }); | |
| 67 | - | ||
| 68 | - process.on('exit', function() { | ||
| 69 | - assert.strictEqual(testCases.length, testsComplete); | ||
| 70 | - }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments