Skip to content

Commit a9199e6

Browse files
committed
【fix】UT
1 parent ef50985 commit a9199e6

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

test/mapboxgl/overlay/ThreeLayerSpec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import {MeshPhongMaterial, Mesh, PointLight, BoxBufferGeometry} from 'three';
22
import {ThreeLayer} from '../../../src/mapboxgl/overlay/ThreeLayer';
33
import mapboxgl from 'mapbox-gl';
4+
import mbglmap from '../../tool/mock_mapboxgl_map';
45

56

67
mapboxgl.accessToken = 'pk.eyJ1IjoibW9ua2VyIiwiYSI6ImNpd2Z6aTE5YTAwdHEyb2tpOWs2ZzRydmoifQ.LwQMRArUP8Q9P7QApuOIHg';
78
describe('mapboxgl_ThreeLayer', () => {
89
var originalTimeout;
910
var testDiv, map, threeLayer;
1011
beforeAll((done) => {
12+
spyOn(mapboxgl, 'Map').and.callFake(mbglmap);
1113
testDiv = window.document.createElement("div");
1214
testDiv.setAttribute("id", "map");
1315
testDiv.style.styleFloat = "left";

test/tool/mock_mapboxgl_map.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const Map = function (options) {
4949
this.setStyle(options.style);
5050
}
5151
this.transform = {
52+
zoomScale:function () { },
5253
angle: 0
5354
};
5455
this._controlCorners = {
@@ -258,6 +259,9 @@ const Map = function (options) {
258259
this.getPaintProperty = function () { };
259260
this.removeImage = function () { };
260261
this.getCanvasContainer = () => {
262+
if (typeof this._container === 'string') {
263+
return document.getElementById(this._container);
264+
}
261265
return this._container;
262266
};
263267
this.getCanvas = () => {

0 commit comments

Comments
 (0)