test: 1.完善 LayerControl 单测

This commit is contained in:
yanxiong 2022-08-31 15:12:26 +08:00
parent 3bdaeb67cd
commit 0d18636ffa
1 changed files with 12 additions and 25 deletions

View File

@ -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);
});
});