Search in sources :

Example 16 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class DataTypeListItemViewTest method testGetLabels.

@Test
public void testGetLabels() {
    final Element element1 = mock(Element.class);
    final Element element2 = mock(Element.class);
    final HTMLElement viewElement = mock(HTMLElement.class);
    final NodeList<Element> labels = spy(new NodeList<>());
    element1.classList = mock(DOMTokenList.class);
    element2.classList = mock(DOMTokenList.class);
    labels.length = 2;
    doReturn(element1).when(labels).getAt(0);
    doReturn(element2).when(labels).getAt(0);
    doReturn(viewElement).when(view).getElement();
    when(viewElement.querySelectorAll(".data-type-label")).thenReturn(labels);
    assertEquals(labels, view.getLabels());
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) Test(org.junit.Test)

Example 17 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class DataTypeListItemViewTest method testHideLabels.

@Test
public void testHideLabels() {
    final Element element1 = mock(Element.class);
    final Element element2 = mock(Element.class);
    final NodeList<Element> labels = spy(new NodeList<>());
    element1.classList = mock(DOMTokenList.class);
    element2.classList = mock(DOMTokenList.class);
    labels.length = 2;
    doReturn(element1).when(labels).getAt(0);
    doReturn(element2).when(labels).getAt(1);
    doReturn(labels).when(view).getLabels();
    view.hideLabels();
    verify(element1.classList).add(HIDDEN_CSS_CLASS);
    verify(element2.classList).add(HIDDEN_CSS_CLASS);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) Test(org.junit.Test)

Example 18 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class DataTypeListItemViewTest method makeChildElement.

public Element makeChildElement(final String uuid) {
    final Element element = mock(Element.class);
    element.classList = mock(DOMTokenList.class);
    // This element does not have any child.
    mockDOMElementsByParentUUID(uuid, new NodeList<>());
    when(element.getAttribute("data-row-uuid")).thenReturn(uuid);
    return element;
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) Element(elemental2.dom.Element) HTMLInputElement(elemental2.dom.HTMLInputElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement)

Example 19 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class DNDListDOMHelperTest method testGetVisibleAndSortedDraggableElements.

@Test
public void testGetVisibleAndSortedDraggableElements() {
    final String selector = ".kie-dnd-draggable";
    final HTMLElement element0 = mock(HTMLElement.class);
    final HTMLElement element1 = mock(HTMLElement.class);
    final HTMLElement element2 = mock(HTMLElement.class);
    final NodeList<Element> nodeList = spy(new NodeList<>());
    nodeList.length = 3;
    doReturn(element0).when(nodeList).getAt(0);
    doReturn(element1).when(nodeList).getAt(1);
    doReturn(element2).when(nodeList).getAt(2);
    doReturn("1").when(element0).getAttribute(DATA_Y_POSITION);
    doReturn("0").when(element1).getAttribute(DATA_Y_POSITION);
    doReturn("-1").when(element2).getAttribute(DATA_Y_POSITION);
    doReturn(nodeList).when(element).querySelectorAll(selector);
    final List<HTMLElement> actualElements = querySelector(element).getVisibleAndSortedDraggableElements();
    final List<HTMLElement> expectElements = asList(element1, element0);
    assertEquals(expectElements, actualElements);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) Factory.createGripElement(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListDOMHelper.Factory.createGripElement) HTMLElement(elemental2.dom.HTMLElement) DNDListDOMHelper.isDraggingElement(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListDOMHelper.isDraggingElement) Test(org.junit.Test)

Example 20 with NodeList

use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.

the class DNDListDOMHelperTest method testGetVisibleDraggableElements.

@Test
public void testGetVisibleDraggableElements() {
    final String selector = ".kie-dnd-draggable";
    final HTMLElement element0 = mock(HTMLElement.class);
    final HTMLElement element1 = mock(HTMLElement.class);
    final HTMLElement element2 = mock(HTMLElement.class);
    final NodeList<Element> nodeList = spy(new NodeList<>());
    nodeList.length = 3;
    doReturn(element0).when(nodeList).getAt(0);
    doReturn(element1).when(nodeList).getAt(1);
    doReturn(element2).when(nodeList).getAt(2);
    doReturn("1").when(element0).getAttribute(DATA_Y_POSITION);
    doReturn("0").when(element1).getAttribute(DATA_Y_POSITION);
    doReturn("-1").when(element2).getAttribute(DATA_Y_POSITION);
    doReturn(nodeList).when(element).querySelectorAll(selector);
    final List<HTMLElement> actualElements = querySelector(element).getVisibleDraggableElements();
    final List<HTMLElement> expectElements = asList(element0, element1);
    assertEquals(expectElements, actualElements);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) Factory.createGripElement(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListDOMHelper.Factory.createGripElement) HTMLElement(elemental2.dom.HTMLElement) DNDListDOMHelper.isDraggingElement(org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListDOMHelper.isDraggingElement) Test(org.junit.Test)

Aggregations

Element (elemental2.dom.Element)36 HTMLElement (elemental2.dom.HTMLElement)33 Test (org.junit.Test)24 HTMLDivElement (elemental2.dom.HTMLDivElement)18 HTMLButtonElement (elemental2.dom.HTMLButtonElement)16 DOMTokenList (elemental2.dom.DOMTokenList)15 DataType (org.kie.workbench.common.dmn.client.editors.types.common.DataType)9 HTMLInputElement (elemental2.dom.HTMLInputElement)8 HTMLAnchorElement (elemental2.dom.HTMLAnchorElement)7 NodeList (elemental2.dom.NodeList)4 Factory.createGripElement (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListDOMHelper.Factory.createGripElement)4 DNDListDOMHelper.isDraggingElement (org.kie.workbench.common.dmn.client.editors.types.listview.draganddrop.DNDListDOMHelper.isDraggingElement)4 HTMLDocument (elemental2.dom.HTMLDocument)3 HTMLBodyElement (elemental2.dom.HTMLBodyElement)2 Node (elemental2.dom.Node)2 CSSStyleDeclaration (elemental2.dom.CSSStyleDeclaration)1 Window (elemental2.dom.Window)1 ArrayList (java.util.ArrayList)1 DataTypeConstraint (org.kie.workbench.common.dmn.client.editors.types.listview.constraint.DataTypeConstraint)1