Skip to content

Commit 4855aa0

Browse files
【fix】 UT getDrawLiveData覆盖率, Lang引入路径问题
AI-GEN: 70% Cursor
1 parent b1ec6c8 commit 4855aa0

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎src/mapboxgl/control/VideoMapDrawControl.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This program are made available under the terms of the Apache License, Version 2.0
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
44
import '../core/Base';
5-
import { Lang } from '../../common/lang/Lang';
5+
import { Lang } from '@supermapgis/iclient-common/lang/Lang';
66
import {
77
MODE_SIMPLE_SELECT,
88
MODE_DRAW_POINT,

‎test/mapboxgl/mapping/VideoMapSpec.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ describe('mapboxgl_videoMap', () => {
363363

364364
expect(videoMap.getDrawMode()).toBeNull();
365365
expect(videoMap.getDrawData().features.length).toBe(0);
366+
expect(videoMap.getDrawLiveData()).toEqual({ type: 'FeatureCollection', features: [] });
366367

367368
videoMap.startDraw('Point');
368369
expect(videoMap.getDrawMode()).toBe('Point');
@@ -376,17 +377,28 @@ describe('mapboxgl_videoMap', () => {
376377
videoMap.startDraw('LineString');
377378
videoMap.map.fire('click', { lngLat: { lng: 11587478.81, lat: 3570800.19 } });
378379
videoMap.map.fire('click', { lngLat: { lng: 11587578.81, lat: 3570900.19 } });
380+
var lineLiveData = videoMap.getDrawLiveData();
381+
expect(lineLiveData.features.length).toBe(4);
382+
expect(lineLiveData.features.filter(function (item) {
383+
return item.properties.draft;
384+
}).length).toBe(3);
385+
expect(lineLiveData.features.filter(function (item) {
386+
return item.id === 'videomap-draw-draft-line';
387+
}).length).toBe(1);
379388
expect(videoMap.finishDraw().geometry.type).toBe('LineString');
380389
expect(videoMap.getDrawData().features.length).toBe(2);
390+
expect(videoMap.getDrawLiveData().features.length).toBe(2);
381391

382392
videoMap.startDraw('Polygon');
383393
videoMap.map.fire('click', { lngLat: { lng: 11587478.81, lat: 3570800.19 } });
384394
videoMap.map.fire('click', { lngLat: { lng: 11587578.81, lat: 3570800.19 } });
385395
videoMap.map.fire('click', { lngLat: { lng: 11587578.81, lat: 3570900.19 } });
396+
expect(videoMap.getDrawLiveData().features.length).toBe(6);
386397
var polygon = videoMap.finishDraw();
387398
expect(polygon.geometry.type).toBe('Polygon');
388399
expect(polygon.geometry.coordinates[0].length).toBe(4);
389400
expect(videoMap.getDrawData().features.length).toBe(3);
401+
expect(videoMap.getDrawLiveData().features.length).toBe(3);
390402

391403
videoMap.cancelDraw();
392404
expect(videoMap.getDrawMode()).toBeNull();

0 commit comments

Comments
 (0)