@@ -495,4 +495,79 @@ describe('matchesQuery', function() {
495
495
expect ( matchesQuery ( message , q ) ) . toBe ( false ) ;
496
496
497
497
} ) ;
498
+
499
+ function pointer ( className , objectId ) {
500
+ return { __type : 'Pointer' , className, objectId } ;
501
+ }
502
+
503
+ it ( 'should support containedIn with pointers' , ( ) => {
504
+ var message = {
505
+ id : new Id ( 'Message' , 'O1' ) ,
506
+ profile : pointer ( 'Profile' , 'abc' )
507
+ } ;
508
+ var q = new Parse . Query ( 'Message' ) ;
509
+ q . containedIn ( 'profile' , [ Parse . Object . fromJSON ( { className : 'Profile' , objectId : 'abc' } ) ,
510
+ Parse . Object . fromJSON ( { className : 'Profile' , objectId : 'def' } ) ] ) ;
511
+ expect ( matchesQuery ( message , q ) ) . toBe ( true ) ;
512
+
513
+ q = new Parse . Query ( 'Message' ) ;
514
+ q . containedIn ( 'profile' , [ Parse . Object . fromJSON ( { className : 'Profile' , objectId : 'ghi' } ) ,
515
+ Parse . Object . fromJSON ( { className : 'Profile' , objectId : 'def' } ) ] ) ;
516
+ expect ( matchesQuery ( message , q ) ) . toBe ( false ) ;
517
+ } ) ;
518
+
519
+ it ( 'should support notContainedIn with pointers' , ( ) => {
520
+ var message = {
521
+ id : new Id ( 'Message' , 'O1' ) ,
522
+ profile : pointer ( 'Profile' , 'abc' )
523
+ } ;
524
+ var q = new Parse . Query ( 'Message' ) ;
525
+ q . notContainedIn ( 'profile' , [ Parse . Object . fromJSON ( { className : 'Profile' , objectId : 'def' } ) ,
526
+ Parse . Object . fromJSON ( { className : 'Profile' , objectId : 'ghi' } ) ] ) ;
527
+ expect ( matchesQuery ( message , q ) ) . toBe ( true ) ;
528
+
529
+ message = {
530
+ id : new Id ( 'Message' , 'O1' ) ,
531
+ profile : pointer ( 'Profile' , 'def' )
532
+ } ;
533
+ q = new Parse . Query ( 'Message' ) ;
534
+ q . notContainedIn ( 'profile' , [ Parse . Object . fromJSON ( { className : 'Profile' , objectId : 'ghi' } ) ,
535
+ Parse . Object . fromJSON ( { className : 'Profile' , objectId : 'def' } ) ] ) ;
536
+ expect ( matchesQuery ( message , q ) ) . toBe ( false ) ;
537
+ } ) ;
538
+
539
+ it ( 'should support containedIn queries with [objectId]' , ( ) => {
540
+ var message = {
541
+ id : new Id ( 'Message' , 'O1' ) ,
542
+ profile : pointer ( 'Profile' , 'abc' )
543
+ } ;
544
+ var q = new Parse . Query ( 'Message' ) ;
545
+ q . containedIn ( 'profile' , [ 'abc' , 'def' ] ) ;
546
+ expect ( matchesQuery ( message , q ) ) . toBe ( true ) ;
547
+
548
+ message = {
549
+ id : new Id ( 'Message' , 'O1' ) ,
550
+ profile : pointer ( 'Profile' , 'ghi' )
551
+ } ;
552
+ q = new Parse . Query ( 'Message' ) ;
553
+ q . containedIn ( 'profile' , [ 'abc' , 'def' ] ) ;
554
+ expect ( matchesQuery ( message , q ) ) . toBe ( false ) ;
555
+ } ) ;
556
+
557
+ it ( 'should support notContainedIn queries with [objectId]' , ( ) => {
558
+ var message = {
559
+ id : new Id ( 'Message' , 'O1' ) ,
560
+ profile : pointer ( 'Profile' , 'ghi' )
561
+ } ;
562
+ var q = new Parse . Query ( 'Message' ) ;
563
+ q . notContainedIn ( 'profile' , [ 'abc' , 'def' ] ) ;
564
+ expect ( matchesQuery ( message , q ) ) . toBe ( true ) ;
565
+ message = {
566
+ id : new Id ( 'Message' , 'O1' ) ,
567
+ profile : pointer ( 'Profile' , 'ghi' )
568
+ } ;
569
+ q = new Parse . Query ( 'Message' ) ;
570
+ q . notContainedIn ( 'profile' , [ 'abc' , 'def' , 'ghi' ] ) ;
571
+ expect ( matchesQuery ( message , q ) ) . toBe ( false ) ;
572
+ } ) ;
498
573
} ) ;
0 commit comments