Search in sources :

Example 1 with JQuery

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

the class MenuInitializerTest method testInit.

@Test
public void testInit() {
    final JQuery jQuery = mock(JQuery.class);
    final JQuery.CallbackFunction moveDropDownToBody = mock(JQuery.CallbackFunction.class);
    final JQuery.CallbackFunction moveDropDownToKebabContainer = mock(JQuery.CallbackFunction.class);
    final Element dropdown = mock(Element.class);
    doReturn(dropdown).when(initializer).dropdown();
    doReturn(moveDropDownToBody).when(initializer).moveDropDownToBody();
    doReturn(moveDropDownToKebabContainer).when(initializer).moveDropDownToKebabContainer();
    doReturn(jQuery).when(initializer).jQuery(dropdown);
    initializer.init();
    verify(jQuery).on("show.bs.dropdown", moveDropDownToBody);
    verify(jQuery).on("hidden.bs.dropdown", moveDropDownToKebabContainer);
}
Also used : Element(elemental2.dom.Element) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLElement(elemental2.dom.HTMLElement) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Example 2 with JQuery

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

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

the class DataTypeConstraintModalViewTest method testSetupOnHideHandler.

@Test
public void testSetupOnHideHandler() {
    final HTMLElement body = mock(HTMLElement.class);
    final Node modalBody = mock(Node.class);
    final Node modalContent = mock(Node.class);
    final Node modalDialog = mock(Node.class);
    final Node modalComponent = mock(Node.class);
    final Command command = mock(Command.class);
    final JQuery jQuery = mock(JQuery.class);
    final ArgumentCaptor<CallbackFunction> captor = ArgumentCaptor.forClass(CallbackFunction.class);
    body.parentNode = modalBody;
    modalBody.parentNode = modalContent;
    modalContent.parentNode = modalDialog;
    modalDialog.parentNode = modalComponent;
    doReturn(body).when(view).getBody();
    when(view.constraintModalJQuery()).thenReturn(jQuery);
    view.setupOnHideHandler(command);
    verify(jQuery).on(eq("hidden.bs.modal"), captor.capture());
    captor.getValue().call(mock(JQueryEvent.class));
    verify(command).execute();
}
Also used : CallbackFunction(org.uberfire.client.views.pfly.selectpicker.JQuery.CallbackFunction) HTMLElement(elemental2.dom.HTMLElement) Command(org.uberfire.mvp.Command) JQueryEvent(org.uberfire.client.views.pfly.selectpicker.JQueryEvent) Node(elemental2.dom.Node) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Example 4 with JQuery

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

the class DataTypeShortcutsTest method testClickListenerWhenTabContentDoesNotContainTarget.

@Test
public void testClickListenerWhenTabContentDoesNotContainTarget() {
    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(false);
    shortcuts.clickListener(target);
    verify(listShortcuts).reset();
    verify(listShortcuts, never()).focusIn();
}
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 5 with JQuery

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

the class ScrollHelperTest method testAnimatedScrollToBottomWithTwoArguments.

@Test
public void testAnimatedScrollToBottomWithTwoArguments() {
    final Element element = mock(Element.class);
    final JQuery jQuery = mock(JQuery.class);
    final JavaScriptObject javaScriptObject = mock(JavaScriptObject.class);
    final double scrollHeight = 123;
    when(scrollHelper.elementJQuery(element)).thenReturn(jQuery);
    doReturn(javaScriptObject).when(scrollHelper).property("scrollTop", scrollHeight);
    scrollHelper.animatedScrollToBottom(element, scrollHeight);
    verify(jQuery).animate(javaScriptObject, 800);
}
Also used : JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) 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