22// hungry/js/test/parse_query_test.js
33//
44// Some new tests are added.
5+ 'use strict' ;
6+
7+ const Parse = require ( 'parse/node' ) ;
58
69describe ( 'Parse.Query testing' , ( ) => {
710 it ( "basic query" , function ( done ) {
@@ -1574,6 +1577,29 @@ describe('Parse.Query testing', () => {
15741577 } ) ;
15751578 } ) ;
15761579
1580+ it ( "dontSelect query without conditions" , function ( done ) {
1581+ const RestaurantObject = Parse . Object . extend ( "Restaurant" ) ;
1582+ const PersonObject = Parse . Object . extend ( "Person" ) ;
1583+ const objects = [
1584+ new RestaurantObject ( { location : "Djibouti" } ) ,
1585+ new RestaurantObject ( { location : "Ouagadougou" } ) ,
1586+ new PersonObject ( { name : "Bob" , hometown : "Djibouti" } ) ,
1587+ new PersonObject ( { name : "Tom" , hometown : "Yoloblahblahblah" } ) ,
1588+ new PersonObject ( { name : "Billy" , hometown : "Ouagadougou" } )
1589+ ] ;
1590+
1591+ Parse . Object . saveAll ( objects , function ( ) {
1592+ const query = new Parse . Query ( RestaurantObject ) ;
1593+ const mainQuery = new Parse . Query ( PersonObject ) ;
1594+ mainQuery . doesNotMatchKeyInQuery ( "hometown" , "location" , query ) ;
1595+ mainQuery . find ( ) . then ( results => {
1596+ equal ( results . length , 1 ) ;
1597+ equal ( results [ 0 ] . get ( 'name' ) , 'Tom' ) ;
1598+ done ( ) ;
1599+ } ) ;
1600+ } ) ;
1601+ } ) ;
1602+
15771603 it ( "object with length" , function ( done ) {
15781604 var TestObject = Parse . Object . extend ( "TestObject" ) ;
15791605 var obj = new TestObject ( ) ;
@@ -2088,7 +2114,7 @@ describe('Parse.Query testing', () => {
20882114 console . log ( error ) ;
20892115 } ) ;
20902116 } ) ;
2091-
2117+
20922118 // #371
20932119 it ( 'should properly interpret a query' , ( done ) => {
20942120 var query = new Parse . Query ( "C1" ) ;
@@ -2104,30 +2130,30 @@ describe('Parse.Query testing', () => {
21042130 done ( ) ;
21052131 } )
21062132 } ) ;
2107-
2133+
21082134 it ( 'should properly interpret a query' , ( done ) => {
21092135 var user = new Parse . User ( ) ;
21102136 user . set ( "username" , "foo" ) ;
21112137 user . set ( "password" , "bar" ) ;
21122138 return user . save ( ) . then ( ( user ) => {
21132139 var objIdQuery = new Parse . Query ( "_User" ) . equalTo ( "objectId" , user . id ) ;
21142140 var blockedUserQuery = user . relation ( "blockedUsers" ) . query ( ) ;
2115-
2141+
21162142 var aResponseQuery = new Parse . Query ( "MatchRelationshipActivityResponse" ) ;
21172143 aResponseQuery . equalTo ( "userA" , user ) ;
21182144 aResponseQuery . equalTo ( "userAResponse" , 1 ) ;
2119-
2145+
21202146 var bResponseQuery = new Parse . Query ( "MatchRelationshipActivityResponse" ) ;
21212147 bResponseQuery . equalTo ( "userB" , user ) ;
21222148 bResponseQuery . equalTo ( "userBResponse" , 1 ) ;
2123-
2149+
21242150 var matchOr = Parse . Query . or ( aResponseQuery , bResponseQuery ) ;
21252151 var matchRelationshipA = new Parse . Query ( "_User" ) ;
21262152 matchRelationshipA . matchesKeyInQuery ( "objectId" , "userAObjectId" , matchOr ) ;
21272153 var matchRelationshipB = new Parse . Query ( "_User" ) ;
21282154 matchRelationshipB . matchesKeyInQuery ( "objectId" , "userBObjectId" , matchOr ) ;
2129-
2130-
2155+
2156+
21312157 var orQuery = Parse . Query . or ( objIdQuery , blockedUserQuery , matchRelationshipA , matchRelationshipB ) ;
21322158 var query = new Parse . Query ( "_User" ) ;
21332159 query . doesNotMatchQuery ( "objectId" , orQuery ) ;
@@ -2140,8 +2166,8 @@ describe('Parse.Query testing', () => {
21402166 fail ( "should not fail" ) ;
21412167 done ( ) ;
21422168 } ) ;
2143-
2144-
2169+
2170+
21452171 } ) ;
2146-
2172+
21472173} ) ;
0 commit comments