@@ -53,7 +53,6 @@ describe('Parse.GeoPoint testing', () => {
5353 obj . set ( 'name' , 'Zhoul' )
5454 obj . save ( null , {
5555 success : ( obj ) => {
56- console . log ( obj ) ;
5756 Parse . Cloud . httpRequest ( {
5857 url : 'http://localhost:8378/1/classes/TestObject/' + obj . id ,
5958 headers : {
@@ -316,6 +315,21 @@ describe('Parse.GeoPoint testing', () => {
316315 } ) ;
317316 } ) ;
318317
318+ it ( 'returns nearest location' , ( done ) => {
319+ makeSomeGeoPoints ( function ( ) {
320+ var sfo = new Parse . GeoPoint ( 37.6189722 , - 122.3748889 ) ;
321+ var query = new Parse . Query ( TestObject ) ;
322+ query . near ( 'location' , sfo ) ;
323+ query . find ( {
324+ success : function ( results ) {
325+ equal ( results [ 0 ] . get ( 'name' ) , 'San Francisco' ) ;
326+ equal ( results [ 1 ] . get ( 'name' ) , 'Sacramento' ) ;
327+ done ( ) ;
328+ }
329+ } ) ;
330+ } ) ;
331+ } ) ;
332+
319333 it ( 'works with geobox queries' , ( done ) => {
320334 var inSF = new Parse . GeoPoint ( 37.75 , - 122.4 ) ;
321335 var southwestOfSF = new Parse . GeoPoint ( 37.708813 , - 122.526398 ) ;
@@ -376,6 +390,23 @@ describe('Parse.GeoPoint testing', () => {
376390 } ) ;
377391 } ) ;
378392
393+ it ( 'equalTo geopoint' , ( done ) => {
394+ var point = new Parse . GeoPoint ( 44.0 , - 11.0 ) ;
395+ var obj = new TestObject ( ) ;
396+ obj . set ( 'location' , point ) ;
397+ obj . save ( ) . then ( ( ) => {
398+ const query = new Parse . Query ( TestObject ) ;
399+ query . equalTo ( 'location' , point ) ;
400+ return query . find ( ) ;
401+ } ) . then ( ( results ) => {
402+ equal ( results . length , 1 ) ;
403+ const loc = results [ 0 ] . get ( 'location' ) ;
404+ equal ( loc . latitude , point . latitude ) ;
405+ equal ( loc . longitude , point . longitude ) ;
406+ done ( ) ;
407+ } ) ;
408+ } ) ;
409+
379410 it ( 'supports withinPolygon' , ( done ) => {
380411 const point1 = new Parse . GeoPoint ( 1.5 , 1.5 ) ;
381412 const point2 = new Parse . GeoPoint ( 2 , 8 ) ;
0 commit comments