Add test_predicates() to filter.js tests

(imported from commit 551f396b4458ac529858f91f693b424bc7d06b8c)
This commit is contained in:
Steve Howell 2013-08-20 09:50:37 -04:00
parent 269f3670cd
commit 767a8ae400
1 changed files with 11 additions and 5 deletions

View File

@ -19,11 +19,6 @@ var Filter = global.Filter;
var filter = new Filter(operators);
assert.deepEqual(filter.operators(), operators);
var predicate = filter.predicate();
assert(predicate({type: 'stream', stream: 'foo', subject: 'bar'}));
assert(!predicate({type: 'stream', stream: 'foo', subject: 'whatever'}));
assert.deepEqual(filter.operands('stream'), ['foo']);
assert(filter.has_operator('stream'));
@ -50,3 +45,14 @@ var Filter = global.Filter;
assert.deepEqual(Filter.canonicalize_tuple(['Stream', 'Denmark']), ['stream', 'denmark']);
}());
(function test_predicates() {
var operators = [['stream', 'Foo'], ['topic', 'Bar']];
var filter = new Filter(operators);
var predicate = filter.predicate();
assert(predicate({type: 'stream', stream: 'foo', subject: 'bar'}));
assert(!predicate({type: 'stream', stream: 'foo', subject: 'whatever'}));
}());