Skip to content

Commit 695b078

Browse files
committed
fix UT;review by qiw
1 parent b5d9d91 commit 695b078

File tree

4 files changed

+16
-46
lines changed

4 files changed

+16
-46
lines changed

src/maplibregl/overlay/GraphicLayer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* @returns this
4646
*/
4747
addTo(map) {
48-
map.addLayer(this);
48+
this.onAdd(map);
4949
return this;
5050
}
5151

test/maplibregl/overlay/FGBLayerSpec.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('maplibregl_FGBLayer', () => {
3939
center: [0, 0],
4040
zoom: 3
4141
});
42-
map.on('load', function() {
42+
map.on('load', function () {
4343
done();
4444
});
4545
});
@@ -110,7 +110,6 @@ describe('maplibregl_FGBLayer', () => {
110110

111111
it('render moveLayer onRemove setVisibility', (done) => {
112112
var fgblayer = new FGBLayer({
113-
id: 'FGBLayer_1',
114113
url: fgbUrl,
115114
extent: [0, 0, 21, 21],
116115
featureLoader: function (feature) {

test/maplibregl/overlay/GraphicLayerSpec.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('maplibregl_GraphicLayer', () => {
4343
graphicLayer = new GraphicLayer("graphicLayer", {
4444
graphics: graphics
4545
});
46-
graphicLayer.onAdd(map);
46+
graphicLayer.addTo(map);
4747
return graphicLayer
4848
}
4949
beforeEach(() => {
@@ -196,32 +196,14 @@ describe('maplibregl_GraphicLayer', () => {
196196
}, 0);
197197
});
198198

199-
it("addTo moveTo onRemove render", (done) => {
200-
let graphics = [];
201-
for (let i = 0; i < coors.length; i++) {
202-
let lngLat = {
203-
lng: parseFloat(coors[i][0]),
204-
lat: parseFloat(coors[i][1])
205-
};
206-
graphics.push(new Graphic(lngLat));
207-
graphics[i].setId(i);
208-
graphics[i].setAttributes({ name: "graphic_" + i });
209-
}
210-
let graphicLayer1 = new GraphicLayer("graphicLayer1", {
211-
graphics: graphics
212-
});
213-
let map = new maplibregl.Map({
214-
container: 'map',
215-
style: 'mapbox://styles/mapbox/streets-v9',
216-
center: [13.413952, 52.531913],
217-
zoom: 16.000000000000004,
218-
pitch: 33.2
219-
});
220-
graphicLayer1.addTo(map);
221-
graphicLayer1.render();
222-
graphicLayer1.moveTo('test', true);
223-
graphicLayer1.onRemove();
224-
expect(graphicLayer1.renderer.graphics.length).toEqual(0);
225-
done();
199+
it("moveTo onRemove render", (done) => {
200+
let graphicLayer = creatGraphicLayer();
201+
setTimeout(() => {
202+
graphicLayer.render();
203+
graphicLayer.moveTo('test', true);
204+
graphicLayer.onRemove();
205+
expect(graphicLayer.renderer.graphics.length).toEqual(0);
206+
done();
207+
}, 0);
226208
});
227209
});

test/maplibregl/overlay/ThreeLayerSpec.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ describe('maplibregl_ThreeLayer', () => {
2323
zoom: 16.000000000000004,
2424
pitch: 33.2
2525
});
26-
27-
2826
});
2927
beforeEach(() => {
3028
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
@@ -57,16 +55,6 @@ describe('maplibregl_ThreeLayer', () => {
5755
[13.413977, 52.532063]
5856
];
5957
threeLayer = new ThreeLayer('three');
60-
threeLayer.draw = (gl, scene, camera) => {
61-
var light = new PointLight(0xffffff);
62-
camera.add(light);
63-
var height = 10;
64-
var color = 0xff2200;
65-
var material = new MeshPhongMaterial({color: color});
66-
var mesh = threeLayer.toThreeMesh(coordinates, height, material, true);
67-
scene.add(mesh);
68-
};
69-
7058
threeLayer.onAdd(map);
7159

7260
setTimeout(() => {
@@ -176,8 +164,9 @@ describe('maplibregl_ThreeLayer', () => {
176164
});
177165

178166
it('render _update draw', () => {
179-
expect(threeLayer.render()).not.toBeNull();
180-
const _this = threeLayer._update();
181-
expect(_this.draw()).not.toBeNull();
167+
var threeLayer1 = new ThreeLayer('three1');
168+
threeLayer1.onAdd(map);
169+
threeLayer1.render();
170+
expect(threeLayer1.draw()).not.toBeNull();
182171
});
183172
});

0 commit comments

Comments
 (0)