diff --git a/test/localhost.test.js b/test/localhost.test.js index 23facf49..1a47ee92 100644 --- a/test/localhost.test.js +++ b/test/localhost.test.js @@ -6,23 +6,23 @@ const http = require('http'); const request = require('request'); test('can connect from all localhost addresses', t => { - const server = http.createServer(ecstatic(`${__dirname}/public/subdir`)); - t.on('end', () => { server.close(); }); - server.listen(0, () => { - const port = server.address().port; - const addresses = [ - 'localhost', - '127.0.0.1', - '::1', - ]; + const server = http.createServer(ecstatic(`${__dirname}/public/subdir`)); + t.on('end', () => { server.close(); }); + server.listen(0, () => { + const port = server.address().port; + const addresses = [ + 'localhost', + '127.0.0.1', + '::1', + ]; - t.plan(addresses.length * 2); - - for (const address of addresses) { - request.get(`http://${address}:${port}/index.html`, (err, res, body) => { - t.error(err); - t.equal(res.statusCode, 200); - }); - } - }); -}); \ No newline at end of file + t.plan(addresses.length * 2); + + for (const address of addresses) { + request.get(`http://[${address}]:${port}/index.html`, (err, res, body) => { + t.error(err); + t.equal(res.statusCode, 200); + }); + } + }); +});