From 7e9dacdb01367e12582a6c89834556dfda820633 Mon Sep 17 00:00:00 2001 From: qiwei Date: Mon, 30 Sep 2024 11:42:19 +0800 Subject: [PATCH] fix ut --- .../__tests__/AnimateMarkerLayer.spec.js | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/mapboxgl/web-map/layer/animate-marker/__tests__/AnimateMarkerLayer.spec.js b/src/mapboxgl/web-map/layer/animate-marker/__tests__/AnimateMarkerLayer.spec.js index 4cd972c1..43d5be52 100644 --- a/src/mapboxgl/web-map/layer/animate-marker/__tests__/AnimateMarkerLayer.spec.js +++ b/src/mapboxgl/web-map/layer/animate-marker/__tests__/AnimateMarkerLayer.spec.js @@ -498,4 +498,50 @@ describe('AnimateMarkerLayer.vue', () => { expect(wrapper.vm.viewModel.layerId).toBe('test-id2'); done(); }); + + it('change marker opacity', async done => { + const newFeatures= { + features: [ + { + geometry: { + type: 'Point', + coordinates: [122, 53] + }, + properties: { + SmID: '10' + }, + type: 'Feature' + } + ], + type: 'FeatureCollection' + }; + wrapper = mount(SmAnimateMarkerLayer, { + propsData: { + features: newFeatures, + mapTarget: 'map', + textField: 'name', + layerId: 'test-id1' + } + }); + await mapSubComponentLoaded(wrapper); + jest.spyOn(wrapper.vm.map, 'getLayer').mockImplementation(() => { + return { + visibility: 'visible', + getPaintProperty() { + return 0.5; + } + }; + }); + const spy2 = jest.spyOn(wrapper.vm.viewModel.markers[0], 'getElement').mockImplementation(() => { + return { + style: { + display: 'block', + opacity: undefined + } + }; + }); + wrapper.vm.viewModel._updateLayer(); + expect(spy2).toHaveBeenCalledTimes(3); + done(); + }); });