Permalink
Browse files

added test for client-side buffer cleanup

  • Loading branch information...
1 parent 15912c2 commit 237499cdfb7e88eb609256f7507331bdb34668e0 @albertyfwu albertyfwu committed Mar 19, 2013
Showing with 24 additions and 4 deletions.
  1. +24 −4 test/server.js
View
@@ -225,12 +225,11 @@ describe('server', function () {
});
});
- describe('close', function () {
- it('should be able to access non-empty writeBuffer at closing', function(done) {
- var opts = {allowUpgrades: false, pingInterval: 10, pingTimeout: 10 };
+ describe.only('close', function () {
+ it('should be able to access non-empty writeBuffer at closing (server)', function(done) {
+ var opts = {allowUpgrades: false};
var engine = listen(opts, function (port) {
var socket = new eioc.Socket('http://localhost:%d'.s(port));
- socket.sendPacket = function (){};
engine.on('connection', function (conn) {
conn.on('close', function (reason) {
expect(conn.writeBuffer.length).to.be(1);
@@ -245,6 +244,27 @@ describe('server', function () {
});
});
+ it('should be able to access non-empty writeBuffer at closing (client)', function(done) {
+ var opts = {allowUpgrades: false};
+ var engine = listen(opts, function (port) {
+ var socket = new eioc.Socket('http://localhost:%d'.s(port));
+ socket.on('open', function() {
+ socket.on('close', function (reason) {
+ expect(socket.writeBuffer.length).to.be(1);
+ expect(socket.callbackBuffer.length).to.be(1);
+ setTimeout(function() {
+ expect(socket.writeBuffer.length).to.be(0);
+ expect(socket.callbackBuffer.length).to.be(0);
+ }, 10);
+ done();
+ });
+ socket.writeBuffer.push({ type: 'message', data: 'foo'});
+ socket.callbackBuffer.push(function() {});
+ socket.onError('');
+ });
+ });
+ });
+
it('should trigger on server if the client does not pong', function (done) {
var opts = { allowUpgrades: false, pingInterval: 5, pingTimeout: 5 };
var engine = listen(opts, function (port) {

0 comments on commit 237499c

Please sign in to comment.