Skip to content

Commit

Permalink
【fix】change init viewmodel timer
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongjiaojiao committed Apr 17, 2024
1 parent 69bbf8a commit d0cd290
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/mapboxgl/web-map/control/legend/Legend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ export default {
}
}
},
loaded() {
created() {
this.viewModel = new LegendViewModel();
},
loaded() {
this.initLegendList();
},
removed() {
Expand Down
5 changes: 1 addition & 4 deletions src/mapboxgl/web-map/control/legend/__tests__/legend.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ describe('Legend.vue', () => {
};
};

beforeEach(() => {});

afterEach(() => {
jest.resetAllMocks();
if (wrapper) {
Expand All @@ -48,11 +46,10 @@ describe('Legend.vue', () => {
const webmap = {
getLegendInfo: () => mapLegends
};
wrapper.vm.$options.loaded.call(wrapper.vm);
wrapper.vm.viewModel.setMap({
webmap
});
wrapper.vm.initLegendList();
wrapper.vm.$options.loaded.call(wrapper.vm);
await wrapper.vm.$nextTick();
expect(wrapper.vm.legendList).not.toEqual({});
expect(wrapper.vm.mapTarget).toBe('map');
Expand Down

0 comments on commit d0cd290

Please sign in to comment.