@@ -32,15 +32,12 @@ import {MultiPolygon} from 'app/models/geometry/multi-polygon';
32
32
import { Point } from 'app/models/geometry/point' ;
33
33
import { Job } from 'app/models/job.model' ;
34
34
import { LocationOfInterest } from 'app/models/loi.model' ;
35
- import { Submission } from 'app/models/submission/submission.model' ;
36
35
import { DataSharingType , Survey } from 'app/models/survey.model' ;
37
36
import { AuthService } from 'app/services/auth/auth.service' ;
38
37
import {
39
38
DrawingToolsService ,
40
39
EditMode ,
41
40
} from 'app/services/drawing-tools/drawing-tools.service' ;
42
- import { GroundPinService } from 'app/services/ground-pin/ground-pin.service' ;
43
- import { LoadingState } from 'app/services/loading-state.model' ;
44
41
import { LocationOfInterestService } from 'app/services/loi/loi.service' ;
45
42
import { NavigationService } from 'app/services/navigation/navigation.service' ;
46
43
import { SubmissionService } from 'app/services/submission/submission.service' ;
@@ -56,6 +53,7 @@ describe('MapComponent', () => {
56
53
let mockLois$ : BehaviorSubject < List < LocationOfInterest > > ;
57
54
let loiServiceSpy : jasmine . SpyObj < LocationOfInterestService > ;
58
55
let mockLocationOfInterestId$ : BehaviorSubject < string | null > ;
56
+ let mockTaskId$ : BehaviorSubject < string | null > ;
59
57
let navigationServiceSpy : jasmine . SpyObj < NavigationService > ;
60
58
let submissionServiceSpy : jasmine . SpyObj < SubmissionService > ;
61
59
let mockEditMode$ : BehaviorSubject < EditMode > ;
@@ -179,6 +177,7 @@ describe('MapComponent', () => {
179
177
'NavigationService' ,
180
178
[
181
179
'getLocationOfInterestId$' ,
180
+ 'getTaskId$' ,
182
181
'getSubmissionId$' ,
183
182
'selectLocationOfInterest' ,
184
183
'clearLocationOfInterestId' ,
@@ -189,6 +188,10 @@ describe('MapComponent', () => {
189
188
navigationServiceSpy . getLocationOfInterestId$ . and . returnValue (
190
189
mockLocationOfInterestId$
191
190
) ;
191
+ mockTaskId$ = new BehaviorSubject < string | null > ( null ) ;
192
+ navigationServiceSpy . getTaskId$ . and . returnValue (
193
+ mockTaskId$
194
+ ) ;
192
195
navigationServiceSpy . getSubmissionId$ . and . returnValue (
193
196
of < string | null > ( null )
194
197
) ;
@@ -254,16 +257,16 @@ describe('MapComponent', () => {
254
257
) ;
255
258
} ) ) ;
256
259
257
- it ( 'should render markers on map' , ( ) => {
260
+ fit ( 'should render markers on map' , ( ) => {
258
261
expect ( component . markers . size ) . toEqual ( 2 ) ;
259
262
const marker1 = component . markers . get ( poiId1 ) ! ;
260
263
assertMarkerLatLng ( marker1 , new google . maps . LatLng ( 4.56 , 1.23 ) ) ;
261
- assertMarkerIcon ( marker1 , jobColor1 , 30 ) ;
262
- expect ( marker1 . getMap ( ) ) . toEqual ( component . map . googleMap ! ) ;
264
+ expect ( marker1 . element . innerHTML ) . toContain ( `fill=" ${ jobColor1 } "` ) ;
265
+ expect ( marker1 . map ) . toEqual ( component . map . googleMap ! ) ;
263
266
const marker2 = component . markers . get ( poiId2 ) ! ;
264
267
assertMarkerLatLng ( marker2 , new google . maps . LatLng ( 45.6 , 12.3 ) ) ;
265
- assertMarkerIcon ( marker2 , jobColor2 , 30 ) ;
266
- expect ( marker2 . getMap ( ) ) . toEqual ( component . map . googleMap ! ) ;
268
+ expect ( marker2 . element . innerHTML ) . toContain ( `fill=" ${ jobColor2 } "` ) ;
269
+ expect ( marker2 . map ) . toEqual ( component . map . googleMap ! ) ;
267
270
} ) ;
268
271
269
272
it ( 'should render polygons on map - polygon loi' , ( ) => {
@@ -324,8 +327,8 @@ describe('MapComponent', () => {
324
327
expect ( component . markers . size ) . toEqual ( 1 ) ;
325
328
const marker1 = component . markers . get ( poiId1 ) ! ;
326
329
assertMarkerLatLng ( marker1 , new google . maps . LatLng ( 4.56 , 1.23 ) ) ;
327
- assertMarkerIcon ( marker1 , jobColor1 , 30 ) ;
328
- expect ( marker1 . getMap ( ) ) . toEqual ( component . map . googleMap ! ) ;
330
+ expect ( marker1 . element . innerHTML ) . toContain ( `fill=" ${ jobColor1 } "` ) ;
331
+ expect ( marker1 . map ) . toEqual ( component . map . googleMap ! ) ;
329
332
} ) ) ;
330
333
331
334
it ( 'should fit the map when survey changed' , fakeAsync ( ( ) => {
@@ -362,12 +365,12 @@ describe('MapComponent', () => {
362
365
expect ( component . markers . size ) . toEqual ( 2 ) ;
363
366
const marker1 = component . markers . get ( poiId2 ) ! ;
364
367
assertMarkerLatLng ( marker1 , new google . maps . LatLng ( 45.7 , 12.3 ) ) ;
365
- assertMarkerIcon ( marker1 , jobColor2 , 30 ) ;
366
- expect ( marker1 . getMap ( ) ) . toEqual ( component . map . googleMap ! ) ;
368
+ expect ( marker1 . element . innerHTML ) . toContain ( `fill=" ${ jobColor2 } "` ) ;
369
+ expect ( marker1 . map ) . toEqual ( component . map . googleMap ! ) ;
367
370
const marker2 = component . markers . get ( poiId3 ) ! ;
368
371
assertMarkerLatLng ( marker2 , new google . maps . LatLng ( 78.9 , 78.9 ) ) ;
369
- assertMarkerIcon ( marker2 , jobColor2 , 30 ) ;
370
- expect ( marker2 . getMap ( ) ) . toEqual ( component . map . googleMap ! ) ;
372
+ expect ( marker2 . element . innerHTML ) . toContain ( `fill=" ${ jobColor2 } "` ) ;
373
+ expect ( marker2 . map ) . toEqual ( component . map . googleMap ! ) ;
371
374
expect ( component . polygons . size ) . toEqual ( 1 ) ;
372
375
const [ polygon ] = component . polygons . get ( polygonLoiId1 ) ! ;
373
376
assertPolygonPaths ( polygon , [
@@ -393,14 +396,6 @@ describe('MapComponent', () => {
393
396
) . toHaveBeenCalledOnceWith ( poiId1 ) ;
394
397
} ) ;
395
398
396
- it ( 'should enlarge the marker when loi is selected' , fakeAsync ( ( ) => {
397
- mockLocationOfInterestId$ . next ( poiId1 ) ;
398
- tick ( ) ;
399
-
400
- const marker1 = component . markers . get ( poiId1 ) ! ;
401
- assertMarkerIcon ( marker1 , jobColor1 , 50 ) ;
402
- } ) ) ;
403
-
404
399
it ( 'should select loi when polygon is clicked' , ( ) => {
405
400
const [ polygon ] = component . polygons . get ( polygonLoiId1 ) ! ;
406
401
google . maps . event . trigger ( polygon , 'click' , {
@@ -435,17 +430,17 @@ describe('MapComponent', () => {
435
430
436
431
it ( 'markers are not draggable by default' , ( ) => {
437
432
const marker1 = component . markers . get ( poiId1 ) ! ;
438
- expect ( marker1 . getDraggable ( ) ) . toBeFalse ( ) ;
433
+ expect ( marker1 . gmpDraggable ) . toBeFalse ( ) ;
439
434
const marker2 = component . markers . get ( poiId2 ) ! ;
440
- expect ( marker2 . getDraggable ( ) ) . toBeFalse ( ) ;
435
+ expect ( marker2 . gmpDraggable ) . toBeFalse ( ) ;
441
436
} ) ;
442
437
443
438
it ( 'should set marker draggable when loi is selected' , fakeAsync ( ( ) => {
444
439
mockLocationOfInterestId$ . next ( poiId1 ) ;
445
440
tick ( ) ;
446
441
447
442
const marker1 = component . markers . get ( poiId1 ) ! ;
448
- expect ( marker1 . getDraggable ( ) ) . toBeTrue ( ) ;
443
+ expect ( marker1 . gmpDraggable ) . toBeTrue ( ) ;
449
444
} ) ) ;
450
445
451
446
it ( 'should not set marker draggable when loi is selected and drawing tools turned off' , fakeAsync ( ( ) => {
@@ -454,7 +449,7 @@ describe('MapComponent', () => {
454
449
tick ( ) ;
455
450
456
451
const marker1 = component . markers . get ( poiId1 ) ! ;
457
- expect ( marker1 . getDraggable ( ) ) . toBeFalse ( ) ;
452
+ expect ( marker1 . gmpDraggable ) . toBeFalse ( ) ;
458
453
} ) ) ;
459
454
460
455
it ( 'reposition dialog is not displayed by default' , ( ) => {
@@ -662,24 +657,11 @@ describe('MapComponent', () => {
662
657
} ) ) ;
663
658
664
659
function assertMarkerLatLng (
665
- marker : google . maps . Marker ,
660
+ marker : google . maps . marker . AdvancedMarkerElement ,
666
661
latLng : google . maps . LatLng
667
662
) : void {
668
- expect ( marker . getPosition ( ) ?. lat ( ) ) . toEqual ( latLng . lat ( ) ) ;
669
- expect ( marker . getPosition ( ) ?. lng ( ) ) . toEqual ( latLng . lng ( ) ) ;
670
- }
671
-
672
- function assertMarkerIcon (
673
- marker : google . maps . Marker ,
674
- iconColor : string ,
675
- iconSize : number
676
- ) : void {
677
- const icon = marker . getIcon ( ) as google . maps . Icon ;
678
- expect ( atob ( icon . url . slice ( GroundPinService . urlPrefix . length ) ) ) . toContain (
679
- iconColor
680
- ) ;
681
- expect ( icon . scaledSize ?. height ) . toEqual ( iconSize ) ;
682
- expect ( icon . scaledSize ?. width ) . toEqual ( iconSize ) ;
663
+ expect ( marker . position ?. lat ) . toEqual ( latLng . lat ( ) ) ;
664
+ expect ( marker . position ?. lng ) . toEqual ( latLng . lng ( ) ) ;
683
665
}
684
666
685
667
function assertPolygonPaths (
0 commit comments