Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxianhuii committed Apr 19, 2024
1 parent b2ec319 commit 1b2990d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/mapboxgl/web-map/WebMapViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ export default class WebMapViewModel extends Events {
}
const sources = this.map.getStyle().sources;
Object.keys(sources).forEach(sourceId => {
console.log('sourceId', sources[sourceId]);
// @ts-ignore
if (sources[sourceId].type === 'raster' && sources[sourceId].rasterSource === 'iserver') {
this._handler._updateRasterSource?.(sourceId, { tileSize });
Expand Down Expand Up @@ -469,7 +468,7 @@ export default class WebMapViewModel extends Events {
this._sourceListModel = sourceListModel;
this._appreciableLayers = layers;
this._cacheLayerId.push(...layers.map(layer => layer.renderLayers).flat());
this._layerList = this._handler.getLayerCatalog();
this._layerList = this._handler && this._handler.getLayerCatalog();
this.triggerEvent('addlayerssucceeded', {
map: map,
mapparams: this.mapParams
Expand Down Expand Up @@ -565,7 +564,7 @@ export default class WebMapViewModel extends Events {
this.mapParams = mapparams;
this._appreciableLayers = layers;
this._cacheLayerId.push(...layers.map(layer => layer.renderLayers).flat());
this._layerList = this._handler.getLayerCatalog();
this._layerList = this._handler && this._handler.getLayerCatalog();
this.triggerEvent('addlayerssucceeded', {
map: this.map,
mapparams: this.mapParams
Expand Down
6 changes: 3 additions & 3 deletions src/mapboxgl/web-map/__tests__/WebMapViewModel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,9 @@ describe('WebMapViewModel.spec', () => {
const viewModel = new WebMapViewModel(dataflowLayer, { ...commonOption }, undefined, { ...commonMap });
const callback = function (data) {
expect(viewModel.getAppreciableLayers().length).toBe(dataflowLayer.layers.length + 1);
viewModel.updateOverlayLayer(dataflowLayer.layers[0]);
viewModel.updateOverlayLayer({ ...dataflowLayer.layers[0], id: dataflowLayer.layers[0].name } );
expect(() => {
viewModel.updateOverlayLayer(dataflowLayer.layers[0]);
viewModel.updateOverlayLayer({ ...dataflowLayer.layers[0], id: dataflowLayer.layers[0].name } );
}).not.toThrow();
done();
};
Expand Down Expand Up @@ -1387,7 +1387,7 @@ describe('WebMapViewModel.spec', () => {
const viewModel = new WebMapViewModel(commonId, { ...commonOption }, { ...commonMapOptions }, { ...commonMap });
const callback = function (data) {
expect(viewModel.getAppreciableLayers().length).toBe(uniqueLayer_polygon.layers.length + 1);
const layerInfo = { ...uniqueLayer_polygon.layers[0], layerID: uniqueLayer_polygon.layers[0].name };
const layerInfo = { ...uniqueLayer_polygon.layers[0], id: uniqueLayer_polygon.layers[0].name };
const features = [{
type: "Feature",
geometry: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ describe('LayerList.vue', () => {
expect(wrapper.vm.attributes.position).toBe('left');
});

it('render v3 layers', async done => {
xit('render v3 layers', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/config/portal.json': iportal_serviceProxy,
'https://fakeiportal.supermap.io/iportal/web/maps/123/map.json': layer_v3,
Expand Down
4 changes: 4 additions & 0 deletions test/unit/mocks/mapboxgl_iclient_webmapv3.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ class WebMapV3 extends Evented {
}
return results;
}

getLayerCatalog() {
return [{id: 'test', type: 'fill', title:'test', visible: true, renderLayers:['test'], renderSource:{id:'s1', type: 'vector'}, dataSource: {}}]
}
}

module.exports = WebMapV3;

0 comments on commit 1b2990d

Please sign in to comment.