Permalink
Browse files

test syntax cleanup

  • Loading branch information...
1 parent ebee5c3 commit 09355ed6fa407783832bbab51e8b0c8aa3fa7b0b @einaros einaros committed Jan 1, 2012
View
22 test/BufferPool.test.js
@@ -6,16 +6,16 @@ describe('BufferPool', function() {
it('allocates pool', function() {
var db = new BufferPool(1000);
db.size.should.eql(1000);
- })
- })
+ });
+ });
describe('#get', function() {
it('grows the pool if necessary', function() {
var db = new BufferPool(1000);
var buf = db.get(2000);
db.size.should.be.above(1000);
db.used.should.eql(2000);
buf.length.should.eql(2000);
- })
+ });
it('grows the pool after the first call, if necessary', function() {
var db = new BufferPool(1000);
var buf = db.get(1000);
@@ -26,29 +26,29 @@ describe('BufferPool', function() {
db.used.should.eql(2000);
db.size.should.be.above(1000);
buf2.length.should.eql(1000);
- })
+ });
it('grows the pool according to the growStrategy if necessary', function() {
var db = new BufferPool(1000, function(db, length) {
return db.size + 2345;
});
var buf = db.get(2000);
db.size.should.eql(3345);
buf.length.should.eql(2000);
- })
+ });
it('doesnt grow the pool if theres enough room available', function() {
var db = new BufferPool(1000);
var buf = db.get(1000);
db.size.should.eql(1000);
buf.length.should.eql(1000);
- })
- })
+ });
+ });
describe('#reset', function() {
it('shinks the pool', function() {
var db = new BufferPool(1000);
var buf = db.get(2000);
db.reset(true);
db.size.should.eql(1000);
- })
+ });
it('shrinks the pool according to the shrinkStrategy', function() {
var db = new BufferPool(1000, function(db, length) {
return db.used + length;
@@ -58,6 +58,6 @@ describe('BufferPool', function() {
var buf = db.get(2000);
db.reset(true);
db.size.should.eql(0);
- })
- })
-})
+ });
+ });
+});
View
30 test/Receiver.test.js
@@ -16,7 +16,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotData.should.be.ok;
- })
+ });
it('can parse close message', function() {
var p = new Parser();
var packet = '88 00';
@@ -28,7 +28,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotClose.should.be.ok;
- })
+ });
it('can parse masked text message', function() {
var p = new Parser();
var packet = '81 93 34 83 a8 68 01 b9 92 52 4f a1 c6 09 59 e6 8a 52 16 e6 cb 00 5b a1 d5';
@@ -41,7 +41,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotData.should.be.ok;
- })
+ });
it('can parse a masked text message longer than 125 bytes', function() {
var p = new Parser();
var message = 'A';
@@ -56,7 +56,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotData.should.be.ok;
- })
+ });
it('can parse a really long masked text message', function() {
var p = new Parser();
var message = 'A';
@@ -71,7 +71,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotData.should.be.ok;
- })
+ });
it('can parse a fragmented masked text message of 300 bytes', function() {
var p = new Parser();
var message = 'A';
@@ -90,7 +90,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet1));
p.add(getBufferFromHexString(packet2));
gotData.should.be.ok;
- })
+ });
it('can parse a ping message', function() {
var p = new Parser();
var message = 'Hello';
@@ -104,7 +104,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotPing.should.be.ok;
- })
+ });
it('can parse a ping with no data', function() {
var p = new Parser();
var packet = '89 00';
@@ -116,7 +116,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotPing.should.be.ok;
- })
+ });
it('can parse a fragmented masked text message of 300 bytes with a ping in the middle', function() {
var p = new Parser();
var message = 'A';
@@ -147,7 +147,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet2));
gotData.should.be.ok;
gotPing.should.be.ok;
- })
+ });
it('can parse a fragmented masked text message of 300 bytes with a ping in the middle, which is delievered over sevaral tcp packets', function() {
var p = new Parser();
var message = 'A';
@@ -182,7 +182,7 @@ describe('Receiver', function() {
}
gotData.should.be.ok;
gotPing.should.be.ok;
- })
+ });
it('can parse a 100 byte long masked binary message', function() {
var p = new Parser();
var length = 100;
@@ -199,7 +199,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotData.should.be.ok;
- })
+ });
it('can parse a 256 byte long masked binary message', function() {
var p = new Parser();
var length = 256;
@@ -216,7 +216,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotData.should.be.ok;
- })
+ });
it('can parse a 200kb long masked binary message', function() {
var p = new Parser();
var length = 200 * 1024;
@@ -233,7 +233,7 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotData.should.be.ok;
- })
+ });
it('can parse a 200kb long unmasked binary message', function() {
var p = new Parser();
var length = 200 * 1024;
@@ -250,6 +250,6 @@ describe('Receiver', function() {
p.add(getBufferFromHexString(packet));
gotData.should.be.ok;
- })
-})
+ });
+});
View
14 test/Sender.test.js
@@ -8,21 +8,21 @@ describe('Sender', function() {
sendBufferCacheSize: 10
});
sender._sendCache.length.should.eql(10);
- })
+ });
it('keeps a send cache equal to null if options.sendBufferCacheSize is 0', function() {
var sender = new Sender(null, {
sendBufferCacheSize: 0
});
(typeof sender._sendCache).should.eql('undefined');
- })
+ });
it('keeps a send cache equal to null if options.sendBufferCacheSize is -1', function() {
var sender = new Sender(null, {
sendBufferCacheSize: -1
});
(typeof sender._sendCache).should.eql('undefined');
- })
+ });
describe('#frameAndSend', function() {
it('does not modify a masked binary buffer', function() {
@@ -34,13 +34,13 @@ describe('Sender', function() {
buf[2].should.eql(3);
buf[3].should.eql(4);
buf[4].should.eql(5);
- })
+ });
it('does not modify a masked text buffer', function() {
var sender = new Sender({ write: function() {} });
var text = 'hi there';
sender.frameAndSend(1, text, true, true);
text.should.eql('hi there');
- })
- })
-})
+ });
+ });
+});
View
12 test/Validation.test.js
@@ -7,18 +7,18 @@ describe('Validation', function() {
it('should return true for a valid utf8 string', function() {
var validBuffer = new Buffer('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque gravida mattis rhoncus. Donec iaculis, metus quis varius accumsan, erat mauris condimentum diam, et egestas erat enim ut ligula. Praesent sollicitudin tellus eget dolor euismod euismod. Nullam ac augue nec neque varius luctus. Curabitur elit mi, consequat ultricies adipiscing mollis, scelerisque in erat. Phasellus facilisis fermentum ullamcorper. Nulla et sem eu arcu pharetra pellentesque. Praesent consectetur tempor justo, vel iaculis dui ullamcorper sit amet. Integer tristique viverra ullamcorper. Vivamus laoreet, nulla eget suscipit eleifend, lacus lectus feugiat libero, non fermentum erat nisi at risus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut pulvinar dignissim tellus, eu dignissim lorem vulputate quis. Morbi ut pulvinar augue.');
Validation.isValidUTF8(validBuffer).should.be.ok;
- })
+ });
it('should return false for an erroneous string', function() {
var invalidBuffer = new Buffer([0xce, 0xba, 0xe1, 0xbd, 0xb9, 0xcf, 0x83, 0xce, 0xbc, 0xce, 0xb5, 0xed, 0xa0, 0x80, 0x65, 0x64, 0x69, 0x74, 0x65, 0x64]);
Validation.isValidUTF8(invalidBuffer).should.not.be.ok;
- })
+ });
it('should return true for valid cases from the autobahn test suite', function() {
Validation.isValidUTF8(new Buffer('\xf0\x90\x80\x80')).should.be.ok;
Validation.isValidUTF8(new Buffer([0xf0, 0x90, 0x80, 0x80])).should.be.ok;
- })
+ });
it('should return false for erroneous autobahn strings', function() {
Validation.isValidUTF8(new Buffer([0xce, 0xba, 0xe1, 0xbd])).should.not.be.ok;
- })
- })
-})
+ });
+ });
+});
View
4 test/WebSocket.integration.js
@@ -38,5 +38,5 @@ describe('WebSocket', function() {
ws.terminate();
dataReceived = true;
});
- })
-})
+ });
+});
View
124 test/WebSocket.test.js
@@ -34,8 +34,8 @@ describe('WebSocket', function() {
catch (e) {
done();
}
- })
- })
+ });
+ });
describe('properties', function() {
it('#url exposes the server url', function(done) {
@@ -49,7 +49,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
describe('#readyState', function() {
it('defaults to connecting', function(done) {
@@ -98,7 +98,7 @@ describe('WebSocket', function() {
});
});
});
- })
+ });
var readyStates = {
CONNECTING: 0,
@@ -118,7 +118,7 @@ describe('WebSocket', function() {
});
});
});
- })
+ });
it('can disconnect before connection is established', function(done) {
server.createServer(++port, function(srv) {
@@ -132,7 +132,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('can close before connection is established', function(done) {
server.createServer(++port, function(srv) {
@@ -146,7 +146,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('invalid server key is denied', function(done) {
server.createServer(++port, server.handlers.invalidKey, function(srv) {
@@ -156,7 +156,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('close event is raised when server closes connection', function(done) {
server.createServer(++port, server.handlers.closeAfterConnect, function(srv) {
@@ -166,7 +166,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
describe('#ping', function() {
it('before connect should fail', function(done) {
@@ -182,7 +182,7 @@ describe('WebSocket', function() {
done();
}
});
- })
+ });
it('without message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -196,7 +196,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -211,7 +211,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with encoded message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -227,8 +227,8 @@ describe('WebSocket', function() {
done();
});
});
- })
- })
+ });
+ });
describe('#pong', function() {
it('without message is successfully transmitted to the server', function(done) {
@@ -243,7 +243,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -258,7 +258,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with encoded message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -274,8 +274,8 @@ describe('WebSocket', function() {
done();
});
});
- })
- })
+ });
+ });
describe('#send', function() {
it('very long binary data can be sent and received (with echoing server)', function(done) {
@@ -294,7 +294,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('can send and receive text data', function(done) {
server.createServer(++port, function(srv) {
@@ -309,7 +309,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('send and receive binary data as an array', function(done) {
server.createServer(++port, function(srv) {
@@ -327,7 +327,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('binary data can be sent and received as buffer', function(done) {
server.createServer(++port, function(srv) {
@@ -344,7 +344,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('before connect should fail', function(done) {
server.createServer(++port, function(srv) {
@@ -359,7 +359,7 @@ describe('WebSocket', function() {
done();
}
});
- })
+ });
it('before connect should pass error through callback, if present', function(done) {
server.createServer(++port, function(srv) {
@@ -372,7 +372,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('without data should be successful', function(done) {
server.createServer(++port, function(srv) {
@@ -387,7 +387,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('calls optional callback when flushed', function(done) {
server.createServer(++port, function(srv) {
@@ -400,7 +400,7 @@ describe('WebSocket', function() {
});
});
});
- })
+ });
it('with unencoded message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -415,7 +415,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with encoded message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -431,7 +431,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with unencoded binary message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -449,7 +449,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with encoded binary message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -468,7 +468,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with binary stream will send fragmented data', function(done) {
server.createServer(++port, function(srv) {
@@ -493,7 +493,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with text stream will send fragmented data', function(done) {
server.createServer(++port, function(srv) {
@@ -519,7 +519,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('will cause intermittent send to be delayed in order', function(done) {
server.createServer(++port, function(srv) {
@@ -552,7 +552,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('will cause intermittent stream to be delayed in order', function(done) {
server.createServer(++port, function(srv) {
@@ -585,7 +585,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('will cause intermittent ping to be delivered', function(done) {
server.createServer(++port, function(srv) {
@@ -616,7 +616,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('will cause intermittent pong to be delivered', function(done) {
server.createServer(++port, function(srv) {
@@ -647,7 +647,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('will cause intermittent close to be delivered', function(done) {
server.createServer(++port, function(srv) {
@@ -674,8 +674,8 @@ describe('WebSocket', function() {
assert.equal('foobar', data);
});
});
- })
- })
+ });
+ });
describe('#stream', function() {
it('very long binary data can be streamed', function(done) {
@@ -705,7 +705,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('before connect should pass error through callback', function(done) {
server.createServer(++port, function(srv) {
@@ -718,7 +718,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('without callback should fail', function(done) {
server.createServer(++port, function(srv) {
@@ -735,7 +735,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('will cause intermittent send to be delayed in order', function(done) {
server.createServer(++port, function(srv) {
@@ -775,7 +775,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('will cause intermittent stream to be delayed in order', function(done) {
server.createServer(++port, function(srv) {
@@ -821,7 +821,7 @@ describe('WebSocket', function() {
else throw new Error('more messages than we actually sent just arrived');
});
});
- })
+ });
it('will cause intermittent ping to be delivered', function(done) {
server.createServer(++port, function(srv) {
@@ -859,7 +859,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('will cause intermittent pong to be delivered', function(done) {
server.createServer(++port, function(srv) {
@@ -897,7 +897,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('will cause intermittent close to be delivered', function(done) {
server.createServer(++port, function(srv) {
@@ -935,8 +935,8 @@ describe('WebSocket', function() {
assert.equal('foobar', data);
});
});
- })
- })
+ });
+ });
describe('#close', function() {
it('will raise error callback, if any, if called during send stream', function(done) {
@@ -961,7 +961,7 @@ describe('WebSocket', function() {
}, 1000);
});
});
- })
+ });
it('without invalid first argument throws exception', function(done) {
server.createServer(++port, function(srv) {
@@ -977,7 +977,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('without reserved error code 1004 throws exception', function(done) {
server.createServer(++port, function(srv) {
@@ -993,7 +993,7 @@ describe('WebSocket', function() {
}
});
});
- })
+ });
it('without message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -1008,7 +1008,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -1024,7 +1024,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('with encoded message is successfully transmitted to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -1040,7 +1040,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('ends connection to the server', function(done) {
server.createServer(++port, function(srv) {
@@ -1057,8 +1057,8 @@ describe('WebSocket', function() {
done();
});
});
- })
- })
+ });
+ });
describe('API emulation', function() {
it('should not throw errors when getting and setting', function(done) {
@@ -1118,10 +1118,10 @@ describe('WebSocket', function() {
ws.terminate();
done();
});
- })
+ });
});
});
- })
+ });
describe('ssl', function() {
it('can connect to secure websocket server', function(done) {
@@ -1143,7 +1143,7 @@ describe('WebSocket', function() {
wss.close();
done();
});
- })
+ });
it('cannot connect to secure websocket server via ws://', function(done) {
var options = {
@@ -1191,7 +1191,7 @@ describe('WebSocket', function() {
done();
});
});
- })
+ });
it('can send and receive very long binary data', function(done) {
var options = {
@@ -1225,6 +1225,6 @@ describe('WebSocket', function() {
});
});
});
- })
- })
-})
+ });
+ });
+});
View
56 test/WebSocketServer.test.js
@@ -35,7 +35,7 @@ describe('WebSocketServer', function() {
gotException = true;
}
gotException.should.be.ok;
- })
+ });
it('throws an error if no port or server is specified', function() {
var gotException = false;
@@ -46,12 +46,12 @@ describe('WebSocketServer', function() {
gotException = true;
}
gotException.should.be.ok;
- })
+ });
it('emits an error if http server bind fails', function(done) {
var wss = new WebSocketServer({port: 1});
- wss.on('error', function() { done(); })
- })
+ wss.on('error', function() { done(); });
+ });
it('uses passed server object', function () {
var srv = http.createServer()
@@ -67,7 +67,7 @@ describe('WebSocketServer', function() {
wss.close();
done();
});
- })
+ });
it('works with a precreated http server', function (done) {
var srv = http.createServer();
@@ -80,7 +80,7 @@ describe('WebSocketServer', function() {
done();
});
});
- })
+ });
it('can have two different instances listening on the same http server with two different paths', function(done) {
var srv = http.createServer();
@@ -105,7 +105,7 @@ describe('WebSocketServer', function() {
var ws1 = new WebSocket('ws://localhost:' + port + '/wss1');
var ws2 = new WebSocket('ws://localhost:' + port + '/wss2?foo=1');
});
- })
+ });
it('cannot have two different instances listening on the same http server with two different paths', function(done) {
var srv = http.createServer();
@@ -118,8 +118,8 @@ describe('WebSocketServer', function() {
done();
}
});
- })
- })
+ });
+ });
describe('#close', function() {
it('will close all clients', function(done) {
@@ -136,7 +136,7 @@ describe('WebSocketServer', function() {
});
wss.close();
});
- })
+ });
it('does not close a precreated server', function(done) {
var srv = http.createServer();
@@ -154,7 +154,7 @@ describe('WebSocketServer', function() {
done();
});
});
- })
+ });
it('cleans up websocket data on a precreated server', function(done) {
var srv = http.createServer();
@@ -170,8 +170,8 @@ describe('WebSocketServer', function() {
srv.close();
done();
});
- })
- })
+ });
+ });
it('does not accept connections with no sec-websocket-key', function(done) {
var wss = new WebSocketServer({port: ++port}, function() {
@@ -192,7 +192,7 @@ describe('WebSocketServer', function() {
});
});
wss.on('error', function() {});
- })
+ });
it('does not accept connections with no sec-websocket-version', function(done) {
var wss = new WebSocketServer({port: ++port}, function() {
@@ -214,7 +214,7 @@ describe('WebSocketServer', function() {
});
});
wss.on('error', function() {});
- })
+ });
it('does not accept connections with invalid sec-websocket-version', function(done) {
var wss = new WebSocketServer({port: ++port}, function() {
@@ -237,7 +237,7 @@ describe('WebSocketServer', function() {
});
});
wss.on('error', function() {});
- })
+ });
it('does not accept connections with invalid sec-websocket-origin (8)', function(done) {
var wss = new WebSocketServer({port: ++port, verifyOrigin: function(o) {
@@ -264,7 +264,7 @@ describe('WebSocketServer', function() {
});
});
wss.on('error', function() {});
- })
+ });
it('does not accept connections with invalid origin', function(done) {
var wss = new WebSocketServer({port: ++port, verifyOrigin: function(o) {
@@ -291,7 +291,7 @@ describe('WebSocketServer', function() {
});
});
wss.on('error', function() {});
- })
+ });
it('can send data', function(done) {
var wss = new WebSocketServer({port: ++port}, function() {
@@ -305,7 +305,7 @@ describe('WebSocketServer', function() {
wss.on('connection', function(client) {
client.send('hello!');
});
- })
+ });
describe('properties', function() {
it('protocol is exposed', function(done) {
@@ -317,7 +317,7 @@ describe('WebSocketServer', function() {
wss.close();
done();
});
- })
+ });
it('protocolVersion is exposed', function(done) {
var wss = new WebSocketServer({port: ++port}, function() {
@@ -328,7 +328,7 @@ describe('WebSocketServer', function() {
wss.close();
done();
});
- })
+ });
it('upgradeReq is the original request object', function(done) {
var wss = new WebSocketServer({port: ++port}, function() {
@@ -339,8 +339,8 @@ describe('WebSocketServer', function() {
wss.close();
done();
});
- })
- })
+ });
+ });
describe('#clients', function() {
it('returns a list of connected clients', function(done) {
@@ -353,7 +353,7 @@ describe('WebSocketServer', function() {
wss.close();
done();
});
- })
+ });
it('is updated when client terminates the connection', function(done) {
var ws;
@@ -368,7 +368,7 @@ describe('WebSocketServer', function() {
});
ws.terminate();
});
- })
+ });
it('is updated when client closes the connection', function(done) {
var ws;
@@ -383,7 +383,7 @@ describe('WebSocketServer', function() {
});
ws.close();
});
- })
- })
-})
+ });
+ });
+});
View
2 test/autobahn-server.js
@@ -25,5 +25,5 @@ wss.on('connection', function(ws) {
});
ws.on('error', function() {
console.log('error', arguments);
- })
+ });
});

0 comments on commit 09355ed

Please sign in to comment.