use of elemental2.dom.Event 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);
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class FlashMessagesViewTest method testTeardownDisableErrorHighlightCallbacks.
@Test
public void testTeardownDisableErrorHighlightCallbacks() {
final Element element = mock(Element.class);
final Event event = mock(Event.class);
element.onkeypress = (e) -> false;
element.onblur = (e) -> false;
view.teardownDisableErrorHighlightCallbacks(element);
assertTrue(Boolean.valueOf(element.onkeypress.onInvoke(event).toString()));
assertTrue(Boolean.valueOf(element.onblur.onInvoke(event).toString()));
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class FlashMessagesViewTest method testOnOkWarningButtonClick.
@Test
public void testOnOkWarningButtonClick() {
final ClickEvent event = mock(ClickEvent.class);
doNothing().when(view).disableWarningHighlight();
warningContainer.classList = mock(DOMTokenList.class);
view.onOkWarningButtonClick(event);
verify(presenter).executeSuccessWarningCallback();
verify(warningContainer.classList).remove(OPENED_CONTAINER_CSS_CLASS);
verify(view).disableWarningHighlight();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DataTypeShortcutsTest method testClickListenerWhenDatatypeElementIsClicked.
@Test
public void testClickListenerWhenDatatypeElementIsClicked() {
final Event target = mock(Event.class);
final Element targetElement = mock(Element.class);
final Element targetMenu = mock(Element.class);
final Element dataTypeRowElement = mock(Element.class);
final JQuery jQuery = mock(JQuery.class);
JQuery.$ = jQuery;
target.target = targetElement;
doReturn(targetMenu).when(targetElement).closest(SELECT_DATATYPE_MENU);
doReturn(false).when(shortcuts).tabContentContainsTarget(target);
doReturn(dataTypeRowElement).when(targetElement).closest(".list-group-item");
shortcuts.clickListener(target);
verify(listShortcuts).focusIn();
verify(listShortcuts).highlight(dataTypeRowElement);
verify(listShortcuts, never()).reset();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DataTypeShortcutsTest method testIsSearchBarTargetWhenItReturnsTrue.
@Test
public void testIsSearchBarTargetWhenItReturnsTrue() {
final HTMLInputElement element = mock(HTMLInputElement.class);
event.target = element;
when(element.getAttribute("data-field")).thenReturn("search-bar");
assertTrue(shortcuts.isTargetElementAnInput(event));
}
Aggregations