From c6fed55f53907925fc1d644478ef7a6ff7de1fca Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Tue, 24 Jul 2012 10:39:23 -0700 Subject: [PATCH] tests: fixed tests for 0.8 --- package.json | 2 +- test/common.js | 6 +++++- test/parser.test.js | 12 ++++++------ test/static.test.js | 2 +- test/transports.flashsocket.test.js | 6 +++--- test/transports.jsonp-polling.test.js | 4 ++-- test/transports.xhr-polling.test.js | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index cb98e9ed..8afd810c 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ } , "devDependencies": { "expresso": "0.9.2" - , "should": "0.0.4" + , "should": "*" , "benchmark": "0.2.2" , "microtime": "0.1.3-1" , "colors": "0.5.1" diff --git a/test/common.js b/test/common.js index 56b89521..0ee7b98d 100644 --- a/test/common.js +++ b/test/common.js @@ -103,7 +103,11 @@ HTTPClient.prototype.end = function () { Object.keys(this.agent.sockets).forEach(function (socket) { for (var i = 0, l = self.agent.sockets[socket].length; i < l; ++i) { if (self.agent.sockets[socket][i]._handle) { - self.agent.sockets[socket][i]._handle.socket.end(); + if (self.agent.sockets[socket][i]._handle.socket) { + self.agent.sockets[socket][i]._handle.socket.end(); + } else { + self.agent.sockets[socket][i]._handle.owner.end(); + } } } }); diff --git a/test/parser.test.js b/test/parser.test.js index 13bf4cf9..0d6eb88a 100644 --- a/test/parser.test.js +++ b/test/parser.test.js @@ -95,7 +95,7 @@ module.exports = { 'decoding json packet with message id and ack data': function () { parser.decodePacket('4:1+::{"a":"b"}').should.eql({ type: 'json' - , id: 1 + , id: '1' , ack: 'data' , endpoint: '' , data: { a: 'b' } @@ -114,7 +114,7 @@ module.exports = { 'decoding an event packet with message id and ack': function () { parser.decodePacket('5:1+::{"name":"tobi"}').should.eql({ type: 'event' - , id: 1 + , id: '1' , ack: 'data' , endpoint: '' , name: 'tobi' @@ -143,7 +143,7 @@ module.exports = { 'decoding a message packet with id and endpoint': function () { parser.decodePacket('3:5:/tobi').should.eql({ type: 'message' - , id: 5 + , id: '5' , ack: true , endpoint: '/tobi' , data: '' @@ -245,7 +245,7 @@ module.exports = { 'encoding json packet with message id and ack data': function () { parser.encodePacket({ type: 'json' - , id: 1 + , id: '1' , ack: 'data' , endpoint: '' , data: { a: 'b' } @@ -264,7 +264,7 @@ module.exports = { 'encoding an event packet with message id and ack': function () { parser.encodePacket({ type: 'event' - , id: 1 + , id: '1' , ack: 'data' , endpoint: '' , name: 'tobi' @@ -292,7 +292,7 @@ module.exports = { 'encoding a message packet with id and endpoint': function () { parser.encodePacket({ type: 'message' - , id: 5 + , id: '5' , ack: true , endpoint: '/tobi' , data: '' diff --git a/test/static.test.js b/test/static.test.js index bc97d357..473c7ec2 100644 --- a/test/static.test.js +++ b/test/static.test.js @@ -452,7 +452,7 @@ module.exports = { cl.get('/socket.io/socket.io.js', function (res, data) { res.headers['content-type'].should.eql('application/javascript'); - res.headers['content-length'].should.eql(13); + res.headers['content-length'].should.eql('13'); res.headers.etag.should.eql('1.0'); data.should.eql('custom_client'); diff --git a/test/transports.flashsocket.test.js b/test/transports.flashsocket.test.js index f3753713..482fc161 100644 --- a/test/transports.flashsocket.test.js +++ b/test/transports.flashsocket.test.js @@ -104,7 +104,7 @@ module.exports = { netConnection(port, function (err, data){ should.strictEqual(err, null); - data.toString().should.include.string(''); + data.toString().should.match(//); this.destroy(); io.flashPolicyServer.close(); @@ -133,7 +133,7 @@ module.exports = { netConnection(next, function (err, data){ should.strictEqual(err, null); - data.toString().should.include.string(''); + data.toString().should.match(//); this.destroy(); io.flashPolicyServer.close(); @@ -159,7 +159,7 @@ module.exports = { server.origins.should.not.contain('google.com:80'); server.origins.should.contain('foo.bar:80'); server.origins.should.contain('socket.io:1337'); - server.buffer.toString('utf8').should.include.string('socket.io'); + server.buffer.toString('utf8').should.match(/socket\.io/); io.flashPolicyServer.close(); done(); diff --git a/test/transports.jsonp-polling.test.js b/test/transports.jsonp-polling.test.js index badccacf..83d68f0c 100644 --- a/test/transports.jsonp-polling.test.js +++ b/test/transports.jsonp-polling.test.js @@ -257,7 +257,7 @@ module.exports = { , sid; io.configure(function () { - io.set('close timeout', .05); + io.set('close timeout', .1); }); io.sockets.on('connection', function (socket) { @@ -625,7 +625,7 @@ module.exports = { io.configure(function () { io.set('polling duration', .2); - io.set('close timeout', .2); + io.set('close timeout', .5); }); io.sockets.on('connection', function (socket) { diff --git a/test/transports.xhr-polling.test.js b/test/transports.xhr-polling.test.js index 9a63c2d0..c8ef710e 100644 --- a/test/transports.xhr-polling.test.js +++ b/test/transports.xhr-polling.test.js @@ -1351,7 +1351,7 @@ module.exports = { msgs.should.have.length(1); msgs[0].should.eql({ type: 'ack' - , ackId: 1 + , ackId: '1' , endpoint: '' , args: [] });