Search in sources :

Example 1 with JQueryEvent

use of org.uberfire.client.views.pfly.selectpicker.JQueryEvent 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);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) JSONObject(com.google.gwt.json.client.JSONObject) JQueryEvent(org.uberfire.client.views.pfly.selectpicker.JQueryEvent) JSONNumber(com.google.gwt.json.client.JSONNumber) JSONString(com.google.gwt.json.client.JSONString) Test(org.junit.Test)

Example 2 with JQueryEvent

use of org.uberfire.client.views.pfly.selectpicker.JQueryEvent 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);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JQueryEvent(org.uberfire.client.views.pfly.selectpicker.JQueryEvent) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Example 3 with JQueryEvent

use of org.uberfire.client.views.pfly.selectpicker.JQueryEvent in project kie-wb-common by kiegroup.

the class MenuInitializerTest method testMoveDropDownToBody.

@Test
public void testMoveDropDownToBody() {
    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).bodyDropdownProperties(event);
    doReturn(modalInElement).when(initializer).body();
    when(jsonObjectProperties.getJavaScriptObject()).thenReturn(javaScriptObjectProperties);
    when(jQueryTarget.css(javaScriptObjectProperties)).thenReturn(jQueryCSS);
    when(jQueryCSS.detach()).thenReturn(jQueryDetach);
    when(initializer.jQuery(modalInElement)).thenReturn(jQueryModalIn);
    when(initializer.jQuery(target)).thenReturn(jQueryTarget);
    initializer.moveDropDownToBody().call(event);
    verify(jQueryModalIn).append(jQueryDetach);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JQueryEvent(org.uberfire.client.views.pfly.selectpicker.JQueryEvent) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Aggregations

JSONObject (com.google.gwt.json.client.JSONObject)3 HTMLElement (elemental2.dom.HTMLElement)3 Test (org.junit.Test)3 JQueryEvent (org.uberfire.client.views.pfly.selectpicker.JQueryEvent)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 JQuery (org.uberfire.client.views.pfly.selectpicker.JQuery)2 JSONNumber (com.google.gwt.json.client.JSONNumber)1 JSONString (com.google.gwt.json.client.JSONString)1