Skip to content

Commit

Permalink
stream test using tap
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Nov 3, 2011
1 parent 06ef6b8 commit f0d258f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions test/stream.js
@@ -1,8 +1,9 @@
var assert = require('assert');
var dnode = require('../');
var net = require('net');
var test = require('tap').test;

exports.stream = function () {
test('stream', function (t) {
t.plan(1);
var port = Math.floor(Math.random() * 40000 + 10000);

var server = dnode({
Expand All @@ -12,21 +13,17 @@ exports.stream = function () {
var netServer = net.createServer();
server.listen(netServer);

var to = setTimeout(function () {
assert.fail();
}, 5000);

var times = 0;
netServer.listen(port, function () {
var netClient = net.createConnection(port);
dnode.connect(netClient, function (remote) {
remote.meow(function (cats) {
clearTimeout(to);
assert.equal(cats, 'cats');
t.equal(cats, 'cats');

netClient.end();
netServer.close();
t.end();
});
});
});
};
});

0 comments on commit f0d258f

Please sign in to comment.