diff --git a/test/test.js b/test/test.js index 6db9bb9..ab31f2a 100644 --- a/test/test.js +++ b/test/test.js @@ -183,4 +183,34 @@ async.series([ port.write(msg); }; }, "spreadfactor"); + + test(function(t) { + t.plan(4); + + var i = 0; + + async.doUntil(function(done) { + var write = ports["dev" + (1 + i % 2)]; + var read = ports["dev" + (1 + (i + 1) % 2)]; + + var buf = ""; + var msg = `tick${i}`; + + read.on("data", function onData(c) { + buf += c.toString(); + + if(buf.indexOf(msg) !== -1) { + t.pass("got message " + i); + + read.removeListener("data", onData); + + done(null); + } + }); + + write.write(`send${msg}\n`); + }, function() { + return ++i > 5; + }) + }, "exchange"); });