Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it.skip('legend click', () => {
const lc = view.get('legendController');
const legend = lc.legends[0];
const itemsGroup = legend.get('itemsGroup');
const targetItem = itemsGroup.get('children')[0];
const event1 = new Event('click', {}, true, true);
event1.target = targetItem.get('children')[0];
itemsGroup.emit('click', event1);
const filteredValues = view.getFilteredValues('country');
expect(filteredValues).eql(['Africa', 'Europe', 'Oceania']);
expect(view.get('isUpdate')).to.be.true;
});
onMouseover() {
overCalled = true;
},
onMouseleave() {
leaveCalled = true;
},
});
view.render();
const lc = view.get('legendController');
const legend = lc.legends[0];
const itemsGroup = legend.get('itemsGroup');
const targetItem = itemsGroup.get('children')[0];
const clickEvent = new Event('mousemove', {}, true, true);
clickEvent.target = targetItem.get('children')[0];
itemsGroup.emit('click', clickEvent);
expect(clickCalled).to.be.true;
const mousemoveEvent = new Event('mousemove', {}, true, true);
mousemoveEvent.target = targetItem.get('children')[1];
itemsGroup.emit('mousemove', mousemoveEvent);
expect(overCalled).to.be.true;
const mouseleaveEvent = new Event('mouseleave', {}, true, true);
mouseleaveEvent.target = targetItem.get('children')[1];
itemsGroup.emit('mouseleave', mouseleaveEvent);
expect(leaveCalled).to.be.true;
});
const lc = view.get('legendController');
const legend = lc.legends[0];
const itemsGroup = legend.get('itemsGroup');
const targetItem = itemsGroup.get('children')[0];
const clickEvent = new Event('mousemove', {}, true, true);
clickEvent.target = targetItem.get('children')[0];
itemsGroup.emit('click', clickEvent);
expect(clickCalled).to.be.true;
const mousemoveEvent = new Event('mousemove', {}, true, true);
mousemoveEvent.target = targetItem.get('children')[1];
itemsGroup.emit('mousemove', mousemoveEvent);
expect(overCalled).to.be.true;
const mouseleaveEvent = new Event('mouseleave', {}, true, true);
mouseleaveEvent.target = targetItem.get('children')[1];
itemsGroup.emit('mouseleave', mouseleaveEvent);
expect(leaveCalled).to.be.true;
});
},
});
view.render();
const lc = view.get('legendController');
const legend = lc.legends[0];
const itemsGroup = legend.get('itemsGroup');
const targetItem = itemsGroup.get('children')[0];
const clickEvent = new Event('mousemove', {}, true, true);
clickEvent.target = targetItem.get('children')[0];
itemsGroup.emit('click', clickEvent);
expect(clickCalled).to.be.true;
const mousemoveEvent = new Event('mousemove', {}, true, true);
mousemoveEvent.target = targetItem.get('children')[1];
itemsGroup.emit('mousemove', mousemoveEvent);
expect(overCalled).to.be.true;
const mouseleaveEvent = new Event('mouseleave', {}, true, true);
mouseleaveEvent.target = targetItem.get('children')[1];
itemsGroup.emit('mouseleave', mouseleaveEvent);
expect(leaveCalled).to.be.true;
});
private _onMousemove(ev: EventType): void {
const item = this._getLegendItem(ev.target);
if (item && item.get('checked')) {
const itemMouseover: EventType = new Event('itemmouseover', ev, true, true);
itemMouseover.item = this._findItem(item);
itemMouseover.checked = item.get('checked');
this.emit('itemmouseover', itemMouseover);
this.get('canvas').draw();
}
}
private _onMouseleave(ev: EventType) {
const item = this._getLegendItem(ev.target);
if (item && item.get('checked')) {
const itemMouseleave: EventType = new Event('itemmouseleave', ev, true, true);
itemMouseleave.item = this._findItem(item);
itemMouseleave.checked = item.get('checked');
this.emit('itemmouseleave', itemMouseleave);
this.get('canvas').draw();
}
}
private _onClick(ev: EventType) {
const clickedItem = this._getLegendItem(ev.target);
if (clickedItem && !clickedItem.get('destroyed')) {
const checked = clickedItem.get('checked');
if (!this.get('allowAllCanceled') && checked && this.getCheckedCount() === 1) {
return;
}
const mode = this.get('selectedMode');
const item = this._findItem(clickedItem);
const itemClick: EventType = new Event('itemclick', ev, true, true);
itemClick.item = item;
itemClick.currentTarget = clickedItem;
itemClick.checked = mode === 'single' ? true : !checked;
const unSelectedColor = this.get('unSelectedColor');
const checkColor = this.get('textStyle').fill;
let markerItem;
let textItem;
let legendItem;
if (mode === 'single') {
const itemsGroup = this.get('itemsGroup');
const children = itemsGroup.get('children');
each(children, (child: GroupType) => {
markerItem = this._findShapeByName(child, 'legend-marker');
textItem = this._findShapeByName(child, 'legend-text');
legendItem = this._findShapeByName(child, 'legend-item');
if (child !== clickedItem) {