From e0ad87182afadaf05b9f56b67e0fd7f42cfa1d96 Mon Sep 17 00:00:00 2001 From: chenxianhui Date: Sun, 28 Jan 2024 00:04:28 +0800 Subject: [PATCH] fix ut --- .../control/identify/__tests__/Identify.spec.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/mapboxgl/web-map/control/identify/__tests__/Identify.spec.js b/src/mapboxgl/web-map/control/identify/__tests__/Identify.spec.js index 470425c1..c869d34f 100644 --- a/src/mapboxgl/web-map/control/identify/__tests__/Identify.spec.js +++ b/src/mapboxgl/web-map/control/identify/__tests__/Identify.spec.js @@ -4,6 +4,7 @@ import Identify from '../index'; import SmWebMap from '../../../WebMap.vue'; import mapLoaded from 'vue-iclient/test/unit/mapLoaded.js'; import { LineStyle, CircleStyle, FillStyle } from '../../../../_types/index'; +import mapboxgl from '@libs/mapboxgl/mapbox-gl-enhance.js'; describe('Identify.vue', () => { let wrapper; @@ -85,6 +86,18 @@ describe('Identify.vue', () => { }; } }); + const spyPopup = jest.spyOn(mapboxgl, 'Popup'); + spyPopup.mockReturnValue({ + setLngLat: jest.fn().mockReturnValue({ + setDOMContent: jest.fn().mockReturnValue({ + addTo: jest.fn().mockReturnValue({ + remove: jest.fn(), + off: jest.fn(), + on: jest.fn() + }) + }) + }) + }); const callback = jest.fn(); identifyWrapper = wrapper.vm.$children[0].$children[0]; identifyWrapper.$on('loaded', callback);