@@ -5,6 +5,63 @@ describe('DataFormatter', () => {
5
5
let dataFormatter ;
6
6
let formattedData = [ ] ;
7
7
8
+ describe ( 'when latitude and longitude are given in table data' , ( ) => {
9
+ beforeEach ( ( ) => {
10
+ const ctrl = {
11
+ panel : { }
12
+ } ;
13
+ dataFormatter = new DataFormatter ( ctrl , { roundValue : ( ) => { } } ) ;
14
+ } ) ;
15
+
16
+ it ( 'should use latitude and longitude if no geohash is given' , ( ) => {
17
+ const tableData = [
18
+ [
19
+ {
20
+ latitude : 1 ,
21
+ longitude : 2
22
+ } ,
23
+ {
24
+ latitude : 3 ,
25
+ longitude : 4
26
+ }
27
+ ]
28
+ ] ;
29
+ const data = [ ] ;
30
+
31
+ dataFormatter . setTableValues ( tableData , data ) ;
32
+
33
+ expect ( data [ 0 ] . locationLatitude ) . to . equal ( 1 ) ;
34
+ expect ( data [ 0 ] . locationLongitude ) . to . equal ( 2 ) ;
35
+ expect ( data [ 1 ] . locationLatitude ) . to . equal ( 3 ) ;
36
+ expect ( data [ 1 ] . locationLongitude ) . to . equal ( 4 ) ;
37
+ } ) ;
38
+
39
+ it ( 'should prefer geohash if given' , ( ) => {
40
+ const tableData = [
41
+ [
42
+ {
43
+ latitude : 1 ,
44
+ longitude : 2 ,
45
+ geohash : 'stq4s3x' // 29.9796, 31.1345
46
+ } ,
47
+ {
48
+ latitude : 3 ,
49
+ longitude : 4 ,
50
+ geohash : 'p05010r' // -89.997, 139.273
51
+ }
52
+ ]
53
+ ] ;
54
+ const data = [ ] ;
55
+
56
+ dataFormatter . setTableValues ( tableData , data ) ;
57
+
58
+ expect ( data [ 0 ] . locationLatitude ) . to . be . within ( 29.9796 , 29.9797 ) ;
59
+ expect ( data [ 0 ] . locationLongitude ) . to . be . within ( 31.1345 , 31.1346 ) ;
60
+ expect ( data [ 1 ] . locationLatitude ) . to . be . within ( - 89.998 , - 89.997 ) ;
61
+ expect ( data [ 1 ] . locationLongitude ) . to . be . within ( 139.272 , 139.273 ) ;
62
+ } ) ;
63
+ } ) ;
64
+
8
65
describe ( 'when the time series data matches the location' , ( ) => {
9
66
beforeEach ( ( ) => {
10
67
const ctrl = {
0 commit comments