@@ -37,12 +37,14 @@ describe('Data (<bind type>) type support', () => {
37
37
t ( 'implicit-string-value' , 'implicit string' ) ,
38
38
t ( 'int-value' , '123' ) ,
39
39
t ( 'decimal-value' , '45.67' ) ,
40
+ t ( 'geopoint-value' , '38.25146813817506 21.758421137528785 0 0' ) ,
40
41
)
41
42
) ,
42
43
bind ( '/root/string-value' ) . type ( 'string' ) . relevant ( modelNodeRelevanceExpression ) ,
43
44
bind ( '/root/implicit-string-value' ) . relevant ( modelNodeRelevanceExpression ) ,
44
45
bind ( '/root/int-value' ) . type ( 'int' ) . relevant ( modelNodeRelevanceExpression ) ,
45
- bind ( '/root/decimal-value' ) . type ( 'decimal' ) . relevant ( modelNodeRelevanceExpression )
46
+ bind ( '/root/decimal-value' ) . type ( 'decimal' ) . relevant ( modelNodeRelevanceExpression ) ,
47
+ bind ( '/root/geopoint-value' ) . type ( 'geopoint' ) . relevant ( modelNodeRelevanceExpression )
46
48
)
47
49
) ,
48
50
body (
@@ -182,6 +184,39 @@ describe('Data (<bind type>) type support', () => {
182
184
expect ( answer . value ) . toBe ( null ) ;
183
185
} ) ;
184
186
} ) ;
187
+
188
+ describe ( 'type="geopoint"' , ( ) => {
189
+ let answer : ModelValueNodeAnswer < 'geopoint' > ;
190
+
191
+ beforeEach ( ( ) => {
192
+ answer = getTypedModelValueNodeAnswer ( '/root/geopoint-value' , 'geopoint' ) ;
193
+ } ) ;
194
+
195
+ it ( 'has a (nullable) structured geopoint static type' , ( ) => {
196
+ interface ExpectedGeopointValue {
197
+ readonly latitude : number ;
198
+ readonly longitude : number ;
199
+ readonly altitude : number | null ;
200
+ readonly accuracy : number | null ;
201
+ }
202
+ expectTypeOf ( answer . value ) . toEqualTypeOf < ExpectedGeopointValue | null > ( ) ;
203
+ } ) ;
204
+
205
+ it ( 'has a GeopointValue populated value' , ( ) => {
206
+ expect ( answer . value ) . toEqual ( {
207
+ accuracy : 0 ,
208
+ altitude : 0 ,
209
+ latitude : 38.25146813817506 ,
210
+ longitude : 21.758421137528785 ,
211
+ } ) ;
212
+ } ) ;
213
+
214
+ it ( 'has an null as blank value' , ( ) => {
215
+ scenario . answer ( modelNodeRelevancePath , 'no' ) ;
216
+ answer = getTypedModelValueNodeAnswer ( '/root/geopoint-value' , 'geopoint' ) ;
217
+ expect ( answer . value ) . toBeNull ( ) ;
218
+ } ) ;
219
+ } ) ;
185
220
} ) ;
186
221
187
222
describe ( 'inputs' , ( ) => {
@@ -202,12 +237,14 @@ describe('Data (<bind type>) type support', () => {
202
237
t ( 'implicit-string-value' , 'implicit string' ) ,
203
238
t ( 'int-value' , '123' ) ,
204
239
t ( 'decimal-value' , '45.67' ) ,
240
+ t ( 'geopoint-value' , '38.25146813817506 21.758421137528785 1000 25' ) ,
205
241
)
206
242
) ,
207
243
bind ( '/root/string-value' ) . type ( 'string' ) . relevant ( inputRelevanceExpression ) ,
208
244
bind ( '/root/implicit-string-value' ) . relevant ( inputRelevanceExpression ) ,
209
245
bind ( '/root/int-value' ) . type ( 'int' ) . relevant ( inputRelevanceExpression ) ,
210
- bind ( '/root/decimal-value' ) . type ( 'decimal' ) . relevant ( inputRelevanceExpression )
246
+ bind ( '/root/decimal-value' ) . type ( 'decimal' ) . relevant ( inputRelevanceExpression ) ,
247
+ bind ( '/root/geopoint-value' ) . type ( 'geopoint' ) . relevant ( inputRelevanceExpression )
211
248
)
212
249
) ,
213
250
body (
@@ -216,6 +253,7 @@ describe('Data (<bind type>) type support', () => {
216
253
input ( '/root/implicit-string-value' ) ,
217
254
input ( '/root/int-value' ) ,
218
255
input ( '/root/decimal-value' ) ,
256
+ input ( '/root/geopoint-value' ) ,
219
257
)
220
258
) ;
221
259
@@ -480,6 +518,104 @@ describe('Data (<bind type>) type support', () => {
480
518
} ) ;
481
519
} ) ;
482
520
} ) ;
521
+
522
+ describe ( 'type="geopoint"' , ( ) => {
523
+ let answer : InputNodeAnswer < 'geopoint' > ;
524
+
525
+ beforeEach ( ( ) => {
526
+ answer = getTypedInputNodeAnswer ( '/root/geopoint-value' , 'geopoint' ) ;
527
+ } ) ;
528
+
529
+ it ( 'has a (nullable) structured geopoint static type' , ( ) => {
530
+ interface ExpectedGeopointValue {
531
+ readonly latitude : number ;
532
+ readonly longitude : number ;
533
+ readonly altitude : number | null ;
534
+ readonly accuracy : number | null ;
535
+ }
536
+ expectTypeOf ( answer . value ) . toEqualTypeOf < ExpectedGeopointValue | null > ( ) ;
537
+ } ) ;
538
+
539
+ it ( 'has a GeopointValue populated value' , ( ) => {
540
+ expect ( answer . value ) . toEqual ( {
541
+ latitude : 38.25146813817506 ,
542
+ longitude : 21.758421137528785 ,
543
+ altitude : 1000 ,
544
+ accuracy : 25 ,
545
+ } ) ;
546
+ expect ( answer . stringValue ) . toEqual ( '38.25146813817506 21.758421137528785 1000 25' ) ;
547
+ } ) ;
548
+
549
+ it ( 'has an null as blank value' , ( ) => {
550
+ scenario . answer ( inputRelevancePath , 'no' ) ;
551
+ answer = getTypedInputNodeAnswer ( '/root/geopoint-value' , 'geopoint' ) ;
552
+ expect ( answer . value ) . toBeNull ( ) ;
553
+ expect ( answer . stringValue ) . toBe ( '' ) ;
554
+ } ) ;
555
+
556
+ it ( 'sets altitude with value zero' , ( ) => {
557
+ scenario . answer ( '/root/geopoint-value' , '-5.299 46.663 0 5' ) ;
558
+ answer = getTypedInputNodeAnswer ( '/root/geopoint-value' , 'geopoint' ) ;
559
+ expect ( answer . value ) . toEqual ( {
560
+ latitude : - 5.299 ,
561
+ longitude : 46.663 ,
562
+ altitude : 0 ,
563
+ accuracy : 5 ,
564
+ } ) ;
565
+ expect ( answer . stringValue ) . toEqual ( '-5.299 46.663 0 5' ) ;
566
+ } ) ;
567
+
568
+ it . each ( [
569
+ 'ZYX %% ABC $$' ,
570
+ 'ZYX %% 1200 10' ,
571
+ '-15.2936673 120.7260063 ABC $$' ,
572
+ '-2.33373 36.7260063 ABC 15' ,
573
+ '20.2936673 -16.7260063 1200 ABCD' ,
574
+ '99 179.99999 1200 0' ,
575
+ '89.999 180.1111 1300 0' ,
576
+ ] ) ( 'has null when incorrect value is passed' , ( expression ) => {
577
+ scenario . answer ( '/root/geopoint-value' , expression ) ;
578
+ answer = getTypedInputNodeAnswer ( '/root/geopoint-value' , 'geopoint' ) ;
579
+ expect ( answer . value ) . toBeNull ( ) ;
580
+ expect ( answer . stringValue ) . toBe ( '' ) ;
581
+ } ) ;
582
+
583
+ it . each ( [
584
+ {
585
+ expression : { latitude : 20.663 , longitude : 16.763 } ,
586
+ expectedAsObject : { latitude : 20.663 , longitude : 16.763 , altitude : null , accuracy : null } ,
587
+ expectedAsText : '20.663 16.763' ,
588
+ } ,
589
+ {
590
+ expression : { latitude : 19.899 , longitude : 100.55559 , accuracy : 15 } ,
591
+ expectedAsObject : { latitude : 19.899 , longitude : 100.55559 , altitude : 0 , accuracy : 15 } ,
592
+ expectedAsText : '19.899 100.55559 0 15' ,
593
+ } ,
594
+ {
595
+ expression : { latitude : 45.111 , longitude : 127.23 , altitude : 1350 } ,
596
+ expectedAsObject : { latitude : 45.111 , longitude : 127.23 , altitude : 1350 , accuracy : null } ,
597
+ expectedAsText : '45.111 127.23 1350' ,
598
+ } ,
599
+ {
600
+ expression : { latitude : 14.66599 , longitude : 179.9009 , altitude : 200 , accuracy : 5 } ,
601
+ expectedAsObject : { latitude : 14.66599 , longitude : 179.9009 , altitude : 200 , accuracy : 5 } ,
602
+ expectedAsText : '14.66599 179.9009 200 5' ,
603
+ } ,
604
+ {
605
+ expression : { latitude : 0 , longitude : 0 , altitude : 0 , accuracy : 0 } ,
606
+ expectedAsObject : null ,
607
+ expectedAsText : '' ,
608
+ } ,
609
+ ] ) (
610
+ 'sets value with GeopointValue object' ,
611
+ ( { expression, expectedAsObject, expectedAsText } ) => {
612
+ scenario . answer ( '/root/geopoint-value' , expression ) ;
613
+ answer = getTypedInputNodeAnswer ( '/root/geopoint-value' , 'geopoint' ) ;
614
+ expect ( answer . value ) . toEqual ( expectedAsObject ) ;
615
+ expect ( answer . stringValue ) . toEqual ( expectedAsText ) ;
616
+ }
617
+ ) ;
618
+ } ) ;
483
619
} ) ;
484
620
485
621
describe ( 'casting fractional values to int' , ( ) => {
0 commit comments