Skip to content
Browse files

added autobahn test

  • Loading branch information...
1 parent 04c07d5 commit bb9cad7c37b2a8561da576ec45b48a29ebad356d @einaros einaros committed
Showing with 29 additions and 0 deletions.
  1. +3 −0 Makefile
  2. +26 −0 test/autobahn.js
View
3 Makefile
@@ -21,4 +21,7 @@ test:
integrationtest:
@$(MAKE) NODE_PATH=lib TESTS="$(ALL_INTEGRATION)" run-integrationtests
+autobahn:
+ @NODE_PATH=lib node test/autobahn.js
+
.PHONY: test
View
26 test/autobahn.js
@@ -0,0 +1,26 @@
+var WebSocket = require('../');
+var currentTest = 1;
+var testCount = null;
+
+function nextTest() {
+ if (currentTest > testCount) return;
+ console.log('Running test case #' + currentTest);
+ var ws = new WebSocket('ws://localhost:9001/runCase?case=' + currentTest + '&agent=easy-websocket');
+ ws.on('message', function(data, flags) {
+ ws.send(data, {binary: flags.binary === true, mask: flags.masked === true});
+ });
+ ws.on('close', function() {
+ currentTest += 1;
+ process.nextTick(nextTest);
+ });
+}
+
+var ws = new WebSocket('ws://localhost:9001/getCaseCount');
+ws.on('message', function(data, flags) {
+ testCount = parseInt(data);
+});
+ws.on('close', function() {
+ if (testCount > 0) {
+ nextTest();
+ }
+});

0 comments on commit bb9cad7

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