Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refuctoring test

this test dosen't pass in some timing in my machine.
so make it not to depends on timeout.
  • Loading branch information...
commit dabc50b011a014de3dfc88ee965be6d06e27299c 1 parent 95f0614
@Jxck Jxck authored
Showing with 16 additions and 21 deletions.
  1. +16 −21 test/server.js
View
37 test/server.js
@@ -820,36 +820,31 @@ describe('server', function () {
it('should execute once for each send', function (done) {
var engine = listen(function (port) {
var socket = new eioc.Socket('ws://localhost:%d'.s(port));
- var i = 0;
- var ic = 0;
- var j = 0;
- var jc = 0;
+ var a = 0;
+ var b = 0;
+ var c = 0;
+ var all = 0;
engine.on('connection', function (conn) {
- conn.send('b', function (transport) {
- jc++;
- });
-
- conn.send('a', function (transport) {
- ic++;
- });
+ conn.send('a');
+ conn.send('b');
+ conn.send('c');
});
socket.on('open', function () {
socket.on('message', function (msg) {
- if (msg == 'a') {
- i++;
- } else if (msg == 'b') {
- j++;
+ if (msg === 'a') a ++;
+ if (msg === 'b') b ++;
+ if (msg === 'c') c ++;
+
+ if(++all === 3) {
+ expect(a).to.be(1);
+ expect(b).to.be(1);
+ expect(c).to.be(1);
+ done();
}
});
});
-
- setTimeout(function () {
- expect(i).to.be(ic);
- expect(j).to.be(jc);
- done();
- }, 100);
});
});
Please sign in to comment.
Something went wrong with that request. Please try again.