16
16
*/
17
17
18
18
import { expect } from 'chai' ;
19
- import { Query } from '../../../src/core/query' ;
19
+ import { Bound , Query } from '../../../src/core/query' ;
20
20
import { DOCUMENT_KEY_NAME , ResourcePath } from '../../../src/model/path' ;
21
21
import { addEqualityMatcher } from '../../util/equality_matcher' ;
22
22
import {
@@ -27,9 +27,37 @@ import {
27
27
filter ,
28
28
orderBy ,
29
29
path ,
30
- ref
30
+ ref ,
31
+ wrap
31
32
} from '../../util/helpers' ;
32
33
34
+ describe ( 'Bound' , ( ) => {
35
+ function makeBound ( values : unknown [ ] , before : boolean ) : Bound {
36
+ return new Bound ( values . map ( el => wrap ( el ) ) , before ) ;
37
+ }
38
+
39
+ it ( 'implements isEqual' , ( ) => {
40
+ let bound = makeBound ( [ 1 , 2 ] , true ) ;
41
+ expect ( bound . isEqual ( makeBound ( [ 1 , 2 ] , true ) ) ) . to . be . true ;
42
+
43
+ // Mismatch values
44
+ expect ( bound . isEqual ( makeBound ( [ 2 , 2 ] , true ) ) ) . to . be . false ;
45
+ expect ( bound . isEqual ( makeBound ( [ 1 , 3 ] , true ) ) ) . to . be . false ;
46
+
47
+ // Mismatch before
48
+ expect ( bound . isEqual ( makeBound ( [ 1 , 2 ] , false ) ) ) . to . be . false ;
49
+
50
+ // Unequal lengths
51
+ expect ( bound . isEqual ( makeBound ( [ ] , true ) ) ) . to . be . false ;
52
+ expect ( bound . isEqual ( makeBound ( [ 1 ] , true ) ) ) . to . be . false ;
53
+ expect ( bound . isEqual ( makeBound ( [ 1 , 2 , 3 ] , true ) ) ) . to . be . false ;
54
+
55
+ // Zero length
56
+ bound = makeBound ( [ ] , false ) ;
57
+ expect ( bound . isEqual ( makeBound ( [ ] , false ) ) ) . to . be . true ;
58
+ } ) ;
59
+ } ) ;
60
+
33
61
describe ( 'Query' , ( ) => {
34
62
addEqualityMatcher ( ) ;
35
63
0 commit comments