From 0d18636ffadfd5bb092601b42abdc89a1eedbb65 Mon Sep 17 00:00:00 2001 From: yanxiong Date: Wed, 31 Aug 2022 15:12:26 +0800 Subject: [PATCH] =?UTF-8?q?test:=201.=E5=AE=8C=E5=96=84=20LayerControl=20?= =?UTF-8?q?=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/__tests__/layerControl.spec.ts | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/packages/component/__tests__/layerControl.spec.ts b/packages/component/__tests__/layerControl.spec.ts index 8de52bc799..6f9881aaba 100644 --- a/packages/component/__tests__/layerControl.spec.ts +++ b/packages/component/__tests__/layerControl.spec.ts @@ -1,32 +1,19 @@ -// import { LineLayer, PointLayer } from '@antv/l7-layers'; import { TestScene } from '@antv/l7-test-utils'; -// import LayerControl from '../src/control/layerControl'; +import LayerControl from '../src/control/layerControl'; describe('layerControl', () => { const scene = TestScene(); - it('layerControl', () => { - // const pointLayer = new PointLayer(); - // const lineLayer = new LineLayer(); - // const control = new LayerControl({}); - // scene.addLayer(pointLayer); - // scene.addControl(control); - // - // const options = control.getOptions().options; - // expect(options.length).toBeGreaterThan(0); - // expect(control.getSelectValue()).toEqual( - // 'mapbox://styles/mapbox/streets-v11', - // ); - // - // const optionList = ((control - // .getPopper() - // .getContent() as HTMLDivElement).querySelectorAll( - // '.l7-select-control-item', - // ) as unknown) as HTMLDivElement[]; - // optionList[1].click(); - // - // expect(control.getSelectValue()).toEqual( - // 'mapbox://styles/zcxduo/ck2ypyb1r3q9o1co1766dex29', - // ); + it('life cycle', () => { + const layerControl = new LayerControl(); + scene.addControl(layerControl); + + const container = layerControl.getContainer(); + expect(container.parentElement).toBeInstanceOf(HTMLElement); + + expect(layerControl.getLayerVisible()).toEqual([]); + + scene.removeControl(layerControl); + expect(container.parentElement).not.toBeInstanceOf(HTMLElement); }); });