@@ -344,7 +344,97 @@ describe('DataFormatter', () => {
344
344
} ) ;
345
345
} ) ;
346
346
347
+ describe ( 'when elasticsearch geohash query result is in table format' , ( ) => {
348
+
349
+ const data : any [ ] = [ ] ;
350
+
351
+ beforeEach ( ( ) => {
352
+
353
+ jQuery . extend ( ctrl , {
354
+ panel : {
355
+ esGeoPoint : 'geopoint' ,
356
+ esMetric : 'metric' ,
357
+ //esLocationName: 'location',
358
+ //esLink: 'link',
359
+ } ,
360
+ } ) ;
361
+
362
+ const esdata = [
363
+ {
364
+ 'type' : 'table' ,
365
+ 'columns' : [
366
+ { text : 'geopoint' } ,
367
+ { text : 'metric' } ,
368
+ ] ,
369
+ 'rows' : [
370
+ [
371
+ 'u0wt6pv2qqhz' ,
372
+ 123.45 ,
373
+ ] ,
374
+ [
375
+ 'u33dbm6duz90' ,
376
+ 67.890 ,
377
+ ] ,
378
+ ] ,
379
+ } ,
380
+ ] ;
381
+
382
+ const dataFormatter = new DataFormatter ( ctrl ) ;
383
+ dataFormatter . setGeohashValues ( esdata , data ) ;
384
+
385
+ } ) ;
386
+
387
+ it ( 'the fields should be available within transformed data' , ( ) => {
388
+ expect ( data [ 0 ] . value ) . toEqual ( 123.45 ) ;
389
+ expect ( data [ 1 ] . value ) . toEqual ( 67.890 ) ;
390
+ } ) ;
391
+
392
+ } ) ;
393
+
394
+ describe ( 'when elasticsearch geohash query result is in timeseries format' , ( ) => {
395
+
396
+ const data : any [ ] = [ ] ;
397
+
398
+ beforeEach ( ( ) => {
399
+
400
+ jQuery . extend ( ctrl , {
401
+ panel : {
402
+ esGeoPoint : 'geopoint' ,
403
+ esMetric : 'metric' ,
404
+ //esLocationName: 'location',
405
+ //esLink: 'link',
406
+ } ,
407
+ } ) ;
408
+
409
+ const esdata = [
410
+ {
411
+ 'datapoints' : [
412
+ {
413
+ geopoint : 'u0wt6pv2qqhz' ,
414
+ metric : 123.45 ,
415
+ } ,
416
+ {
417
+ geopoint : 'u33dbm6duz90' ,
418
+ metric : 67.890 ,
419
+ } ,
420
+ ] ,
421
+ } ,
422
+ ] ;
423
+
424
+ const dataFormatter = new DataFormatter ( ctrl ) ;
425
+ dataFormatter . setGeohashValues ( esdata , data ) ;
426
+
427
+ } ) ;
428
+
429
+ it ( 'the fields should be available within transformed data' , ( ) => {
430
+ expect ( data [ 0 ] . value ) . toEqual ( 123.45 ) ;
431
+ expect ( data [ 1 ] . value ) . toEqual ( 67.890 ) ;
432
+ } ) ;
433
+
434
+ } ) ;
435
+
347
436
afterEach ( ( ) => {
348
437
formattedData = [ ] ;
349
438
} ) ;
439
+
350
440
} ) ;
0 commit comments