1
1
const should = require ( 'chai' ) . Should ( ) ;
2
- const query = require ( '../../lib' ) ;
2
+ const queryable = require ( '../../lib' ) ;
3
3
4
4
describe ( 'Module Tests' , ( ) => {
5
5
@@ -26,26 +26,26 @@ describe('Module Tests', () => {
26
26
}
27
27
] ;
28
28
29
- it ( 'query (arr) should return a query object' , ( ) => {
30
- query ( [ ] ) . should . have . property ( 'every ' ) ;
31
- query ( [ ] ) . should . have . property ( 'some ' ) ;
29
+ it ( 'queryable (arr) should return a queryable object' , ( ) => {
30
+ queryable ( [ ] ) . should . have . property ( 'and ' ) ;
31
+ queryable ( [ ] ) . should . have . property ( 'or ' ) ;
32
32
} ) ;
33
33
34
34
it ( 'throw an error if `arr` is not an array' , ( ) => {
35
35
( ( ) => {
36
- query ( ) ;
36
+ queryable ( ) ;
37
37
} ) . should . throw ( '`arr` must be an array of objects' ) ;
38
38
39
39
( ( ) => {
40
- query ( 'this is a string' ) ;
40
+ queryable ( 'this is a string' ) ;
41
41
} ) . should . throw ( '`arr` must be an array of objects' ) ;
42
42
43
43
( ( ) => {
44
- query ( 1234 ) ;
44
+ queryable ( 1234 ) ;
45
45
} ) . should . throw ( '`arr` must be an array of objects' ) ;
46
46
} ) ;
47
47
48
- it ( 'query (arr).every (filters) should return all results that satisfy all filters' , ( ) => {
48
+ it ( 'queryable (arr).and (filters) should return all results that satisfy all filters' , ( ) => {
49
49
const filters = [
50
50
{
51
51
field : 'name' ,
@@ -59,10 +59,10 @@ describe('Module Tests', () => {
59
59
}
60
60
] ;
61
61
const expected = [ people [ 0 ] ] ;
62
- query ( people ) . every ( filters ) . should . eql ( expected ) ;
62
+ queryable ( people ) . and ( filters ) . should . eql ( expected ) ;
63
63
} ) ;
64
64
65
- it ( 'query (arr).some (filters) should return all results that satisfy at least one of the filters' , ( ) => {
65
+ it ( 'queryable (arr).or (filters) should return all results that satisfy at least one of the filters' , ( ) => {
66
66
const filters = [
67
67
{
68
68
field : 'name' ,
@@ -76,7 +76,7 @@ describe('Module Tests', () => {
76
76
}
77
77
] ;
78
78
const expected = [ people [ 0 ] , people [ 1 ] , people [ 2 ] ] ;
79
- query ( people ) . some ( filters ) . should . eql ( expected ) ;
79
+ queryable ( people ) . or ( filters ) . should . eql ( expected ) ;
80
80
} ) ;
81
81
82
82
} ) ;
0 commit comments