8000 [fix]UT · SuperMap/iClient-JavaScript@278af1e · GitHub
[go: up one dir, main page]

Skip to content

Commit 278af1e

Browse files
[fix]UT
1 parent edc101f commit 278af1e

File tree

1 file changed

+55
-16
lines changed

1 file changed

+55
-16
lines changed

test/mapboxgl/overlay/GraticuleLayerSpec.js

+55-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GraticuleLayer } from '../../../src/mapboxgl/overlay/GraticuleLayer';
22
import mapboxgl from 'mapbox-gl';
3-
// import { Feature } from '@supermap/iclient-common';
3+
// import { Feature } from '@supermapgis/iclient-common';
44
var url = GlobeParameter.ChinaURL + '/zxyTileImage.png?z={z}&x={x}&y={y}';
55

66
describe('mapboxgl_GraticuleLayer', () => {
@@ -45,7 +45,7 @@ describe('mapboxgl_GraticuleLayer', () => {
4545
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
4646
if (!map.getLayer('graticuleLayer_1')) {
4747
graticuleLayer = new GraticuleLayer({ layerID: 'graticuleLayer_1' });
48-
graticuleLayer.onAdd(map);
48+
map.addLayer(graticuleLayer);
4949
}
5050
});
5151

@@ -72,14 +72,13 @@ describe('mapboxgl_GraticuleLayer', () => {
7272
done();
7373
}, 0);
7474
});
75-
75+
7676
it('_initialize visible', (done) => {
7777
setTimeout(() => {
78-
expect(graticuleLayer).not.toBeNull();
7978
const graticuleLayer = new GraticuleLayer({ layerID: 'graticuleLayer_test', visible: false });
8079
graticuleLayer.onAdd(map);
81-
var visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
82-
expect(visible).toBe('false');
80+
var visible = map.getLayoutProperty('graticuleLayer_test_line', 'visibility');
81+
expect(visible).toBe('none');
8382
done();
8483
}, 0);
8584
});
@@ -93,6 +92,20 @@ describe('mapboxgl_GraticuleLayer', () => {
9392
expect(visible).toBe('visible');
9493
});
9594

95+
it('setLayoutProperty', () => {
96+
let visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
97+
expect(visible).toBe('visible');
98+
expect(graticuleLayer.visible).toBeTruthy();
99+
map.setLayoutProperty(graticuleLayer.id, 'visibility', 'none');
100+
visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
101+
expect(visible).toBe('none');
102+
expect(graticuleLayer.visible).toBeFalsy();
103+
map.setLayoutProperty(graticuleLayer.id, 'visibility', 'visible');
104+
visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
105+
expect(visible).toBe('visible');
106+
expect(graticuleLayer.visible).toBeTruthy();
107+
});
108+
96109
it('setMinZoom', () => {
97110
graticuleLayer.setMinZoom(0);
98111
expect(graticuleLayer.options.minZoom).toEqual(0);
@@ -109,12 +122,12 @@ describe('mapboxgl_GraticuleLayer', () => {
109122
});
110123

111124
it('setExtent', () => {
112-
graticuleLayer.setExtent([
113-
[0, 0],
114-
[50, 50]
115-
]);
116-
expect(graticuleLayer.options.extent[0]).toEqual(0);
117-
expect(graticuleLayer.options.extent[3]).toEqual(50);
125+
graticuleLayer.setExtent([
126+
[0, 0],
127+
[50, 50]
128+
]);
129+
expect(graticuleLayer.options.extent[0]).toEqual(0);
130+
expect(graticuleLayer.options.extent[3]).toEqual(50);
118131
});
119132

120133
it('setStrokeStyle', () => {
@@ -133,8 +146,34 @@ describe('mapboxgl_GraticuleLayer', () => {
133146
});
134147

135148
it('setIntervals', () => {
136-
graticuleLayer.setIntervals(5);
137-
expect(graticuleLayer.renderer.options.interval).toEqual(5);
149+
graticuleLayer.setIntervals(5);
150+
expect(graticuleLayer.renderer.options.interval).toEqual(5);
151+
});
152+
153+
it('getDefaultExtent must return degree', () => {
154+
map.getCRS = () => {
155+
return {
156+
extent: [
157+
-20037508.3427892,
158+
-20037508.3427892,
159+
20037508.3427892,
160+
20037508.3427892
161+
],
162+
lngLatExtent: [
163+
-179.99999999999963,
164+
-85.05112877980658,
165+
179.99999999999963,
166+
85.05112877980656
167+
]
168+
};
169+
};
170+
var extent = graticuleLayer.getDefaultExtent();
171+
expect(extent).toEqual([
172+
-179.99999999999963,
173+
-85.05112877980658,
174+
179.99999999999963,
175+
85.05112877980656
176+
]);
138177
});
139178

140179
it('_calcInterval', () => {
@@ -164,8 +203,8 @@ describe('mapboxgl_GraticuleLayer', () => {
164203
expect(points[0][1]).toEqual(80);
165204
});
166205

167-
it('onRemove', () => {
206+
xit('onRemove', () => {
168207
graticuleLayer.onRemove();
169208
expect(graticuleLayer.renderer.canvas).toBeNull();
170209
});
171-
});
210+
});

0 commit comments

Comments
 (0)
0