Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

websocket test now using wsclient

  • Loading branch information...
commit 3f13cd4e12ae7fff22dce1ed347ae07c48bebf78 1 parent 98ba7f4
@substack authored
Showing with 9 additions and 14 deletions.
  1. +1 −1  package.json
  2. +8 −13 test/ws.js
View
2  package.json
@@ -37,7 +37,7 @@
"tap" : "0.0.x",
"lazy" : "1.0.x",
"websocket-server" : "1.4.x",
- "websocket-client" : "1.0.x",
+ "wsclient" : "0.2.x",
"chunky" : "0.0.x"
},
"engines" : {
View
21 test/ws.js
@@ -1,7 +1,7 @@
var test = require('tap').test;
var bouncy = require('../');
var ws = require('websocket-server');
-var wc = require('websocket-client').WebSocket;
+var wc = require('wsclient');
test('ws', function (t) {
t.plan(4);
@@ -15,12 +15,6 @@ test('ws', function (t) {
c.send(msg.split('').reverse().join(''));
if (msgs.length === 0) c.close();
});
-
- c.on('close', function () {
- s0.close();
- s1.close();
- t.end();
- });
});
s0.listen(p0, connect);
@@ -35,7 +29,9 @@ test('ws', function (t) {
function connect () {
if (++connected !== 2) return;
- var c = new wc('ws://localhost:' + p1 + '/', 'biff');
+ var c = wc.websocket('ws://localhost:' + p1 + '/');
+ c.connect();
+
c.on('open', function () {
c.send('beepity');
setTimeout(function () {
@@ -44,15 +40,14 @@ test('ws', function (t) {
});
c.on('close', function () {
+ s0.close();
+ s1.close();
+ t.end();
});
var msgs = [ 'ytipeeb', 'poob' ];
- c.on('data', function (buf) {
+ c.on('message', function (buf) {
t.equal(buf.toString(), msgs.shift());
});
-
- c.on('end', function () {
- t.end();
- });
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.