Skip to content
This repository
Browse code

Merge pull request #114 from Jxck/master

refuctoring test which fales depends on timing
  • Loading branch information...
commit ec9334dc03097d01f4678eec707c253a1011d51a 2 parents ee1eacf + dabc50b
Guillermo Rauch authored November 05, 2012

Showing 1 changed file with 16 additions and 21 deletions. Show diff stats Hide diff stats

  1. 37  test/server.js
37  test/server.js
@@ -826,36 +826,31 @@ describe('server', function () {
826 826
       it('should execute once for each send', function (done) {
827 827
         var engine = listen(function (port) {
828 828
           var socket = new eioc.Socket('ws://localhost:%d'.s(port));
829  
-          var i = 0;
830  
-          var ic = 0;
831  
-          var j = 0;
832  
-          var jc = 0;
  829
+          var a = 0;
  830
+          var b = 0;
  831
+          var c = 0;
  832
+          var all = 0;
833 833
 
834 834
           engine.on('connection', function (conn) {
835  
-            conn.send('b', function (transport) {
836  
-              jc++;
837  
-            });
838  
-
839  
-            conn.send('a', function (transport) {
840  
-              ic++;
841  
-            });
  835
+            conn.send('a');
  836
+            conn.send('b');
  837
+            conn.send('c');
842 838
           });
843 839
 
844 840
           socket.on('open', function () {
845 841
             socket.on('message', function (msg) {
846  
-              if (msg == 'a') {
847  
-                i++;
848  
-              } else if (msg == 'b') {
849  
-                j++;
  842
+              if (msg === 'a') a ++;
  843
+              if (msg === 'b') b ++;
  844
+              if (msg === 'c') c ++;
  845
+
  846
+              if(++all === 3) {
  847
+                expect(a).to.be(1);
  848
+                expect(b).to.be(1);
  849
+                expect(c).to.be(1);
  850
+                done();
850 851
               }
851 852
             });
852 853
           });
853  
-
854  
-          setTimeout(function () {
855  
-            expect(i).to.be(ic);
856  
-            expect(j).to.be(jc);
857  
-            done();
858  
-          }, 100);
859 854
         });
860 855
       });
861 856
 

0 notes on commit ec9334d

Please sign in to comment.
Something went wrong with that request. Please try again.