Skip to content

Commit

Permalink
bidirectional test now using tap
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Nov 3, 2011
1 parent fb56c46 commit aee1992
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -29,7 +29,7 @@
"jsonify" : "0.0.x"
},
"devDependencies" : {
"expresso" : "0.7.x",
"tap" : "0.0.x",
"browserify" : "1.4.x",
"uglify-js" : "1.0.6"
},
Expand Down
19 changes: 10 additions & 9 deletions test/bidirectional.js
@@ -1,17 +1,17 @@
var dnode = require('../');
var assert = require('assert');
var test = require('tap').test;

exports['bidirectional'] = function () {
test('bidirectional', function (t) {
t.plan(5);
var port = Math.floor(Math.random() * 40000 + 10000);

var counts = { timesX : 0, clientX : 0, x : 0 };

var server = dnode(function (client) {
this.timesX = function (n,f) {
assert.equal(n, 3, "timesX's n == 3");
t.equal(n, 3, "timesX's n == 3");
counts.timesX ++;
client.x(function (x) {
assert.equal(x, 20, 'client.x == 20');
t.equal(x, 20, 'client.x == 20');
counts.clientX ++;
f(n * x);
});
Expand All @@ -26,15 +26,16 @@ exports['bidirectional'] = function () {
}
}).connect(port, function (remote, conn) {
remote.timesX(3, function (res) {
assert.equal(res, 60, 'result of 20 * 3 == 60');
t.equal(res, 60, 'result of 20 * 3 == 60');
conn.end();
server.close();
});
});
});

server.once('close', function () {
assert.equal(counts.timesX, 1, 'timesX called once');
assert.equal(counts.clientX, 1, 'clientX called once');
t.equal(counts.timesX, 1, 'timesX called once');
t.equal(counts.clientX, 1, 'clientX called once');
t.end();
});
};
});

0 comments on commit aee1992

Please sign in to comment.