UNPKG

1 kBJavaScriptView Raw
1var Query = require('../lib/query');
2var assert = require('assert');
3
4describe('Query', function() {
5 describe('Constructor', function() {
6 it('implements the .match() prototype.', function() {
7 var q = new Query({});
8 assert.ok(q.match);
9 });
10 });
11
12 describe('match()', function() {
13 it('matches on matching parameters', function() {
14 var q = new Query({test: 'foo', baz: 'bar'});
15
16 var obj = { test: 'foo', baz: 'bar' };
17
18 assert.ok(q.match(obj));
19 });
20
21 it('will not matching on non-matching parameters', function() {
22 var q = new Query({test: 'foo', baz: 'bar'});
23
24 var obj = { test: 'quux', bar: 'baz' };
25
26 assert.ok(!q.match(obj));
27 });
28
29 it('will match everything when an asterisk is the only parameter provided.', function() {
30 var q = new Query('*');
31 var obj = { test: 'quux', bar: 'baz' };
32 var obj2 = { test: 'foo', baz: 'bar' };
33 assert.ok(q.match(obj));
34 assert.ok(q.match(obj2));
35 });
36 });
37});