use of elemental2.dom.EventTarget in project kie-wb-common by kiegroup.
the class DocumentUploadViewImpl method onDragEnd.
private void onDragEnd(Event event) {
if (dropRegion.contains(dropHere)) {
EventTarget relatedTarget = ((DragEvent) event).relatedTarget;
if (relatedTarget.equals(dropHere) || dropHere.contains((Node) relatedTarget)) {
return;
}
restore();
}
}
use of elemental2.dom.EventTarget in project kie-wb-common by kiegroup.
the class ContextMenuViewTest method testWhenGettingEventPathAndPathIsNull.
@Test
public void testWhenGettingEventPathAndPathIsNull() {
final Event event = mock(Event.class);
final Element element = mock(Element.class);
final JsArray<EventTarget> composedPath = spy(new JsArray<>());
final List<EventTarget> composedPathAsList = new ArrayList<>();
final String value = "test-val";
event.path = null;
composedPathAsList.add(element);
doReturn(composedPathAsList).when(composedPath).asList();
when(event.composedPath()).thenReturn(composedPath);
when(element.getAttribute(Mockito.<String>any())).thenReturn(value);
final List<Element> eventPath = contextMenuView.getEventPath(event);
assertThat(eventPath).isNotNull();
assertThat(eventPath).isNotEmpty();
assertThat(eventPath.size()).isEqualTo(1);
assertThat(eventPath.get(0)).extracting(elem -> elem.getAttribute("test-attr")).isEqualTo(value);
}
use of elemental2.dom.EventTarget in project kie-wb-common by kiegroup.
the class ContextMenuViewTest method testWhenGettingEventPath.
@Test
public void testWhenGettingEventPath() {
final Event event = mock(Event.class);
final Element element = mock(Element.class);
final List<EventTarget> pathArray = new ArrayList<>();
final String value = "test-val";
event.path = spy(new JsArray<>());
pathArray.add(element);
doReturn(pathArray).when(event.path).asList();
when(element.getAttribute(Mockito.<String>any())).thenReturn(value);
final List<Element> eventPath = contextMenuView.getEventPath(event);
assertThat(eventPath).isNotNull();
assertThat(eventPath).isNotEmpty();
assertThat(eventPath.size()).isEqualTo(1);
assertThat(eventPath.get(0)).extracting(elem -> elem.getAttribute("test-attr")).isEqualTo(value);
}
Aggregations