use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class AbstractPopoverViewImplTest method testKeyDownEventListenerEscKey.
@Test
public void testKeyDownEventListenerEscKey() {
final KeyboardEvent event = mock(KeyboardEvent.class);
doNothing().when(view).hide();
doNothing().when(view).reset();
doNothing().when(view).onClosedByKeyboard();
doReturn(false).when(view).isEnterKeyPressed(event);
doReturn(true).when(view).isEscapeKeyPressed(event);
view.keyDownEventListener(event);
verify(view).hide();
verify(view).reset();
verify(view).onClosedByKeyboard();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class MenuInitializerTest method testBodyDropdownProperties.
@Test
public void testBodyDropdownProperties() {
final JQueryEvent event = mock(JQueryEvent.class);
final HTMLElement target = mock(HTMLElement.class);
final double left = 1;
final double top = 1;
final double zIndex = 1051;
final JSONObject expectedJSONObject = mock(JSONObject.class);
// Mock "JSONObject" since it relies on a native implementation.
doReturn(expectedJSONObject).when(initializer).makeJsonObject();
event.target = target;
doReturn(left).when(initializer).offsetLeft(target);
doReturn(top).when(initializer).offsetTop(target);
doReturn(top).when(initializer).offsetTop(target);
final JSONObject actualJSONObject = initializer.bodyDropdownProperties(event);
verify(expectedJSONObject).put("position", new JSONString("absolute"));
verify(expectedJSONObject).put("left", new JSONNumber(left));
verify(expectedJSONObject).put("top", new JSONNumber(top));
verify(expectedJSONObject).put("z-index", new JSONNumber(zIndex));
assertEquals(expectedJSONObject, actualJSONObject);
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class MenuInitializerTest method testMoveDropDownToKebabContainer.
@Test
public void testMoveDropDownToKebabContainer() {
final HTMLElement modalInElement = mock(HTMLElement.class);
final HTMLElement target = mock(HTMLElement.class);
final JQuery jQueryModalIn = mock(JQuery.class);
final JQuery jQueryTarget = mock(JQuery.class);
final JQuery jQueryCSS = mock(JQuery.class);
final JQuery jQueryDetach = mock(JQuery.class);
final JQueryEvent event = mock(JQueryEvent.class);
final JSONObject jsonObjectProperties = mock(JSONObject.class);
final JavaScriptObject javaScriptObjectProperties = mock(JavaScriptObject.class);
event.target = target;
doReturn(jsonObjectProperties).when(initializer).emptyProperties();
doReturn(modalInElement).when(initializer).body();
when(jsonObjectProperties.getJavaScriptObject()).thenReturn(javaScriptObjectProperties);
when(jQueryTarget.css(javaScriptObjectProperties)).thenReturn(jQueryCSS);
when(jQueryCSS.detach()).thenReturn(jQueryDetach);
when(initializer.jQuery(kebabMenu)).thenReturn(jQueryModalIn);
when(initializer.jQuery(target)).thenReturn(jQueryTarget);
initializer.moveDropDownToKebabContainer().call(event);
verify(jQueryModalIn).append(jQueryDetach);
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImplTest method testManagerButtonKeyDownEventWhenIsNotKeyboardEvent.
@Test
public void testManagerButtonKeyDownEventWhenIsNotKeyboardEvent() {
final Event event = mock(Event.class);
view.manageButtonKeyDownEventListener(event);
verify(view, never()).hide(false);
verify(view, never()).reset();
verify(view, never()).onClosedByKeyboard();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class ValueAndDataTypePopoverViewImplTest method testTypeSelectorKeyDownEventListenerWhenIsNotAKeyboardEvent.
@Test
public void testTypeSelectorKeyDownEventListenerWhenIsNotAKeyboardEvent() {
final Event event = mock(Event.class);
view.typeSelectorKeyDownEventListener(event);
verify(view, never()).hide(anyBoolean());
verify(event, never()).preventDefault();
verify(view, never()).onClosedByKeyboard();
verify(view, never()).reset();
verify(manageButton, never()).focus();
verify(valueEditor, never()).focus();
}
Aggregations