Skip to content

Commit 0a1cb44

Browse files
committed
Fix unit tests to work with ipv6 and newer node and should.js versions
1 parent 840a3f3 commit 0a1cb44

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

lib/websocket.io.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ exports.listen = function (port, fn, options) {
5959
res.end('Not Implemented');
6060
});
6161

62-
server.listen(port, fn);
62+
server.listen(port || 0, fn);
6363

6464
// create ws server
6565
var ws = exports.attach(server, options);

support/server-common.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ listen = function (options, fn) {
4545
*/
4646

4747
client = function (addr, path) {
48-
var cl = new Client('ws://' + addr.address + ':' + addr.port + (path || ''));
48+
var address = addr.address;
49+
if (addr.family == 'IPv6') {
50+
address = '[' + address + ']';
51+
}
52+
53+
var cl = new Client('ws://' + address + ':' + addr.port + (path || ''));
4954
cl.on('error', function (e) {
5055
throw e;
5156
});

test/websocket.io.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Test dependencies.
44
*/
55

6+
var should = require('should');
67
var ws = require('../lib/websocket.io')
78
, http = require('http')
89

@@ -17,12 +18,12 @@ describe('websocket.io', function () {
1718
});
1819

1920
it('must expose public constructors', function () {
20-
ws.Socket.should.be.a('function');
21-
ws.Server.should.be.a('function');
22-
ws.protocols.drafts.should.be.a('function');
23-
ws.protocols['7'].should.be.a('function');
24-
ws.protocols['8'].should.be.a('function');
25-
ws.protocols['13'].should.be.a('function');
21+
ws.Socket.should.be.a.Function;
22+
ws.Server.should.be.a.Function;
23+
ws.protocols.drafts.should.be.a.Function;
24+
ws.protocols['7'].should.be.a.Function;
25+
ws.protocols['8'].should.be.a.Function;
26+
ws.protocols['13'].should.be.a.Function;
2627
});
2728

2829
it('must connect', function (done) {

0 commit comments

Comments
 (0)