Skip to content

Commit

Permalink
[test] Test .by(Array, reactor).
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Mar 9, 2013
1 parent 8c58441 commit 6b03a94
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
13 changes: 13 additions & 0 deletions test/fixtures/by.json
Expand Up @@ -10,5 +10,18 @@
{
"service": "charlie/app/health/heartbeat",
"ttl": 50
},
{
"service": "charlie/app/health/heartbeat",
"ttl": 100
},
{
"service": "charlie/app/health/memory",
"ttl": 100
},
{
"service": "charlie/app/health/heartbeat",
"ttl": 100
}

]
24 changes: 20 additions & 4 deletions test/reactor/by-test.js
Expand Up @@ -10,7 +10,10 @@ var assert = require('assert'),
godot = require('../../lib/godot'),
macros = require('../macros').reactor;

var count = 0;
var counts = {
service: 0,
'service+ttl': 0
};

vows.describe('godot/reactor/by').addBatch({
"Godot by": {
Expand All @@ -19,16 +22,29 @@ vows.describe('godot/reactor/by').addBatch({
.by(
'service',
godot.reactor().map(function (data) {
count++;
counts.service++;
return data;
})
),
'by',
3
6
),
"[service, ttl]": macros.shouldEmitDataSync(
godot.reactor()
.by(
['service', 'ttl'],
godot.reactor().map(function (data) {
counts['service+ttl']++;
return data;
})
),
'by',
6
)
}
}).addBatch({
"Should emit pipe the events to the correct pipe-chains": function () {
assert.equal(count, 3);
assert.equal(counts.service, 6);
assert.equal(counts['service+ttl'], 12);
}
}).export(module);

0 comments on commit 6b03a94

Please sign in to comment.