Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxianhuii committed Apr 16, 2024
1 parent 6760536 commit 33ca14b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/mapboxgl/web-map/WebMapViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ export default class WebMapViewModel extends Events {
this.mapParams = mapparams;
this._sourceListModel = sourceListModel;
this._appreciableLayers = layers;
this._cacheLayerId.push(...layers.map(layer => layer.id));
this._cacheLayerId.push(...layers.map(layer => layer.renderLayers).flat());
this.triggerEvent('addlayerssucceeded', {
map: map,
mapparams: this.mapParams
Expand Down Expand Up @@ -555,7 +555,7 @@ export default class WebMapViewModel extends Events {
webMapHandler.on('addlayerssucceeded', ({ mapparams, layers }) => {
this.mapParams = mapparams;
this._appreciableLayers = layers;
this._cacheLayerId.push(...layers.map(layer => layer.id));
this._cacheLayerId.push(...layers.map(layer => layer.renderLayers).flat());
this.triggerEvent('addlayerssucceeded', {
map: this.map,
mapparams: this.mapParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ describe('LayerList.vue', () => {
return {
on: (event, callback) => {
callback(commonMap);
}
},
initializeMap: jest.fn(),
clean: jest.fn(),
getLayerCatalog: () => [{id: 'test', type: 'fill', title:'test', visible: true, renderLayers:['test'], renderSource:{id:'s1', type: 'vector'}, dataSource: {}}]
}
}

Expand Down Expand Up @@ -205,7 +208,18 @@ describe('LayerList.vue', () => {
expect(callback.mock.called).toBeTruthy;
expect(wrapper.vm.mapTarget).toBe('map');
wrapper.vm.$nextTick(() => {
wrapper.find('.sm-components-icon-partially-visible').trigger('click');
const item = {
id: 'test',
visible: true,
type: 'group',
children: [{
id: 'test1',
visible: true,
type: 'vector',
renderLayers: ['test1']
}]
}
wrapper.vm.toggleItemVisibility(item)
expect(spyProperty).toHaveBeenCalledTimes(1);
done();
});
Expand Down

0 comments on commit 33ca14b

Please sign in to comment.