-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8a96d0
commit b7c46ac
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const test = require('tap').test; | ||
const ecstatic = require('../lib/core'); | ||
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', | ||
]; | ||
|
||
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); | ||
}); | ||
} | ||
}); | ||
}); |