@@ -53,7 +53,6 @@ describe('Parse.GeoPoint testing', () => {
53
53
obj . set ( 'name' , 'Zhoul' )
54
54
obj . save ( null , {
55
55
success : ( obj ) => {
56
- console . log ( obj ) ;
57
56
Parse . Cloud . httpRequest ( {
58
57
url : 'http://localhost:8378/1/classes/TestObject/' + obj . id ,
59
58
headers : {
@@ -316,6 +315,21 @@ describe('Parse.GeoPoint testing', () => {
316
315
} ) ;
317
316
} ) ;
318
317
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
+
319
333
it ( 'works with geobox queries' , ( done ) => {
320
334
var inSF = new Parse . GeoPoint ( 37.75 , - 122.4 ) ;
321
335
var southwestOfSF = new Parse . GeoPoint ( 37.708813 , - 122.526398 ) ;
@@ -376,6 +390,23 @@ describe('Parse.GeoPoint testing', () => {
376
390
} ) ;
377
391
} ) ;
378
392
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
+
379
410
it ( 'supports withinPolygon' , ( done ) => {
380
411
const point1 = new Parse . GeoPoint ( 1.5 , 1.5 ) ;
381
412
const point2 = new Parse . GeoPoint ( 2 , 8 ) ;
0 commit comments