Permalink
Browse files

move the emit comparison to a much better spot

  • Loading branch information...
1 parent bd6ed40 commit aed21d0ded0d6c781338a1ed49d5cc6da77177fc @substack committed Feb 9, 2013
Showing with 7 additions and 11 deletions.
  1. +7 −11 test/emit.js
View
@@ -31,25 +31,21 @@ test('emit events', function (t) {
};
setTimeout(function () {
+ var times = 0;
var iv = setInterval(function () {
- publish('data', Math.floor(Math.random() * 100));
+ if (++times === 5) {
+ t.deepEqual(xs, ys);
+ return clearInterval(iv);
+ }
+ else publish('data', Math.floor(Math.random() * 100));
}, 20);
-
- t.on('end', function () {
- clearInterval(iv);
- });
}, 20);
var xs = [];
var x = dnode();
x.on('remote', function (remote) {
var em = new EventEmitter;
- em.on('data', function (n) {
- if (xs.length === 6) {
- t.deepEqual(xs, ys);
- }
- xs.push(n);
- });
+ em.on('data', function (n) { xs.push(n) });
remote.subscribe(function () { return em.emit.apply(em, arguments) });
});
x.pipe(server()).pipe(x);

0 comments on commit aed21d0

Please sign in to comment.