Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[test] Added test for cannonical thru example: react to .over() a…
…nd `.under()` independently.
  • Loading branch information
indexzero committed Mar 9, 2013
1 parent 3fb47e7 commit f66656f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions test/fixtures/by.json
@@ -1,26 +1,32 @@
[
{
"service": "charlie/app/health/heartbeat",
"metric": 1,
"ttl": 50
},
{
"service": "charlie/app/health/memory",
"metric": 10,
"ttl": 50
},
{
"service": "charlie/app/health/heartbeat",
"metric": 1,
"ttl": 50
},
{
"service": "charlie/app/health/heartbeat",
"metric": 1,
"ttl": 100
},
{
"service": "charlie/app/health/memory",
"metric": 10,
"ttl": 100
},
{
"service": "charlie/app/health/heartbeat",
"metric": 1,
"ttl": 100
}

Expand Down
26 changes: 25 additions & 1 deletion test/reactor/thru-test.js
Expand Up @@ -10,7 +10,9 @@ var assert = require('assert'),
godot = require('../../lib/godot'),
macros = require('../macros').reactor;

var counts = [0, 0, 0];
var counts = [0, 0, 0],
over = 0,
under = 0;

//
// Helper function to increment the
Expand Down Expand Up @@ -52,11 +54,33 @@ vows.describe('godot/reactor/thru').addBatch({
'by',
6
),
"over under": macros.shouldEmitDataSync(
godot.reactor()
.thru(
godot.reactor()
.over(5)
.map(function (data) {
over++;
return data;
}),
godot.reactor()
.under(5)
.map(function (data) {
under++;
return data;
})
),
'by',
6
)
}
}).addBatch({
"should emit pipe the events to the correct pipe-chains": function () {
counts.forEach(function (length, i) {
assert.equal(length, 6 * (i + 1));
});

assert.equal(over, 2);
assert.equal(under, 4);
}
}).export(module);

0 comments on commit f66656f

Please sign in to comment.