Search in sources :

Example 6 with JQuery

use of org.uberfire.client.views.pfly.selectpicker.JQuery 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)

Example 7 with JQuery

use of org.uberfire.client.views.pfly.selectpicker.JQuery 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();
}
Also used : Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLDivElement(elemental2.dom.HTMLDivElement) Event(elemental2.dom.Event) KeyboardEvent(elemental2.dom.KeyboardEvent) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Example 8 with JQuery

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

the class DataTypeShortcutsTest method testClickListenerWhenDropdownMenuContainsTarget.

@Test
public void testClickListenerWhenDropdownMenuContainsTarget() {
    final Event target = mock(Event.class);
    final Element targetElement = mock(Element.class);
    final Element targetMenu = 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);
    shortcuts.clickListener(target);
    verify(listShortcuts).focusIn();
    verify(listShortcuts, never()).reset();
}
Also used : Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLDivElement(elemental2.dom.HTMLDivElement) Event(elemental2.dom.Event) KeyboardEvent(elemental2.dom.KeyboardEvent) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Example 9 with JQuery

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

the class DataTypeShortcutsTest method testClickListenerWhenConstraintModalFooterContainsTarget.

@Test
public void testClickListenerWhenConstraintModalFooterContainsTarget() {
    final Event target = mock(Event.class);
    final Element targetElement = mock(Element.class);
    final Element targetMenu = mock(Element.class);
    final JQuery jQuery = mock(JQuery.class);
    JQuery.$ = jQuery;
    target.target = targetElement;
    doReturn(targetMenu).when(targetElement).closest(MODAL_FOOTER);
    doReturn(false).when(shortcuts).tabContentContainsTarget(target);
    doReturn(false).when(shortcuts).dropdownMenuContainsTarget(target);
    shortcuts.clickListener(target);
    verify(listShortcuts).focusIn();
    verify(listShortcuts, never()).reset();
}
Also used : Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLDivElement(elemental2.dom.HTMLDivElement) Event(elemental2.dom.Event) KeyboardEvent(elemental2.dom.KeyboardEvent) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Example 10 with JQuery

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

the class DataTypeShortcutsTest method testClickListenerWhenTabContentContainsTarget.

@Test
public void testClickListenerWhenTabContentContainsTarget() {
    final Event target = mock(Event.class);
    final Element targetElement = mock(Element.class);
    final Element tabContentElement = mock(Element.class);
    final JQuery jQuery = mock(JQuery.class);
    JQuery.$ = jQuery;
    target.target = targetElement;
    doReturn(tabContentElement).when(shortcuts).querySelector(".tab-content");
    when(jQuery.contains(tabContentElement, targetElement)).thenReturn(true);
    shortcuts.clickListener(target);
    verify(listShortcuts).focusIn();
    verify(listShortcuts, never()).reset();
}
Also used : Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLDivElement(elemental2.dom.HTMLDivElement) Event(elemental2.dom.Event) KeyboardEvent(elemental2.dom.KeyboardEvent) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 JQuery (org.uberfire.client.views.pfly.selectpicker.JQuery)10 Element (elemental2.dom.Element)7 HTMLDivElement (elemental2.dom.HTMLDivElement)6 Event (elemental2.dom.Event)5 HTMLElement (elemental2.dom.HTMLElement)5 HTMLInputElement (elemental2.dom.HTMLInputElement)5 KeyboardEvent (elemental2.dom.KeyboardEvent)5 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 JQueryEvent (org.uberfire.client.views.pfly.selectpicker.JQueryEvent)3 JSONObject (com.google.gwt.json.client.JSONObject)2 Node (elemental2.dom.Node)1 CallbackFunction (org.uberfire.client.views.pfly.selectpicker.JQuery.CallbackFunction)1 Command (org.uberfire.mvp.Command)1