Search in sources :

Example 31 with NodeList

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

the class DataTypeListItemViewTest method testCollapse.

@Test
public void testCollapse() {
    // Mock arrow element
    final HTMLElement arrow = mock(HTMLElement.class);
    final DOMTokenList arrowClassList = mock(DOMTokenList.class);
    doReturn(arrow).when(view).getArrow();
    arrow.classList = arrowClassList;
    // Mock Parent data type with 2 dependent elements
    final DataType parentDataType = mock(DataType.class);
    final String parentDataTypeUUID = "parentDataTypeUUID";
    final Element parentElement = mock(Element.class);
    final Element child1 = makeChildElement("child1UUID");
    final Element child2 = makeChildElement("child2UUID");
    final NodeList<Element> children = spy(new NodeList<>());
    when(parentDataType.getUUID()).thenReturn(parentDataTypeUUID);
    when(parentElement.getAttribute("data-row-uuid")).thenReturn(parentDataTypeUUID);
    doReturn(parentDataType).when(view).getDataType();
    doReturn(child1).when(children).getAt(0);
    doReturn(child2).when(children).getAt(1);
    mockDOMElementByUUID(parentDataTypeUUID, parentElement);
    mockDOMElementsByParentUUID(parentDataTypeUUID, children);
    children.length = 2;
    view.collapse();
    verify(arrowClassList).remove(DOWN_ARROW_CSS_CLASS);
    verify(arrowClassList).add(RIGHT_ARROW_CSS_CLASS);
    verify(child1.classList).add(HIDDEN_CSS_CLASS);
    verify(child2.classList).add(HIDDEN_CSS_CLASS);
}
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) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 32 with NodeList

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

the class DataTypeListItemViewTest method testShowLabels.

@Test
public void testShowLabels() {
    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.showLabels();
    verify(element1.classList).remove(HIDDEN_CSS_CLASS);
    verify(element2.classList).remove(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 33 with NodeList

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

the class DataTypeListHighlightHelperTest method testAppendBackgroundLine.

@Test
public void testAppendBackgroundLine() {
    final DataType person = mock(DataType.class);
    final DataType personAge = mock(DataType.class);
    final DataType personName = mock(DataType.class);
    final DataType personAddress = mock(DataType.class);
    final String personUUID = "0000";
    final String personAgeUUID = "1111";
    final String personNameUUID = "2222";
    final String personAddressUUID = "3333";
    final String personAddressStreetUUID = "4444";
    final DataType personAddressStreet = mock(DataType.class);
    final DataTypeListItem personItem = mock(DataTypeListItem.class);
    final DataTypeListItem personAgeItem = mock(DataTypeListItem.class);
    final DataTypeListItem personNameItem = mock(DataTypeListItem.class);
    final DataTypeListItem personAddressItem = mock(DataTypeListItem.class);
    final DataTypeListItem personAddressStreetItem = mock(DataTypeListItem.class);
    final Element backgroundLine = mock(Element.class);
    final HTMLElement element = mock(HTMLElement.class);
    final NodeList<Element> nodeList = new NodeList<>();
    backgroundLine.classList = mock(DOMTokenList.class);
    element.offsetHeight = 70;
    nodeList.length = 3;
    doReturn(backgroundLine).when(helper).createElement("div");
    doReturn(nodeList).when(helper).querySelectorAll(".kie-dnd-current-dragging");
    doReturn(Optional.of(personItem)).when(helper).getDataTypeListItem(personUUID);
    doReturn(Optional.of(personAgeItem)).when(helper).getDataTypeListItem(personAgeUUID);
    doReturn(Optional.of(personNameItem)).when(helper).getDataTypeListItem(personNameUUID);
    doReturn(Optional.of(personAddressItem)).when(helper).getDataTypeListItem(personAddressUUID);
    doReturn(Optional.of(personAddressStreetItem)).when(helper).getDataTypeListItem(personAddressStreetUUID);
    when(person.getUUID()).thenReturn(personUUID);
    when(personAge.getUUID()).thenReturn(personAgeUUID);
    when(personName.getUUID()).thenReturn(personNameUUID);
    when(personAddress.getUUID()).thenReturn(personAddressUUID);
    when(personAddressStreet.getUUID()).thenReturn(personAddressStreetUUID);
    when(personItem.isCollapsed()).thenReturn(false);
    when(personAgeItem.isCollapsed()).thenReturn(false);
    when(personNameItem.isCollapsed()).thenReturn(false);
    when(personAddressItem.isCollapsed()).thenReturn(true);
    when(personAddressStreetItem.isCollapsed()).thenReturn(false);
    when(person.getSubDataTypes()).thenReturn(asList(personAge, personName, personAddress));
    when(personAddress.getSubDataTypes()).thenReturn(singletonList(personAddressStreet));
    helper.appendBackgroundLine(person, element);
    verify(backgroundLine.classList).add(LEVEL_BACKGROUND_LINE);
    verify(element).appendChild(backgroundLine);
    verify(backgroundLine).setAttribute("style", "height: 490px");
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) HTMLElement(elemental2.dom.HTMLElement) Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) NodeList(elemental2.dom.NodeList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 34 with NodeList

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

the class DataTypeListHighlightHelperTest method testCleanHighlightClass.

@Test
public void testCleanHighlightClass() {
    final Element element1 = mock(Element.class);
    final Element element2 = mock(Element.class);
    final NodeList<Element> elements = spy(new NodeList<>());
    element1.classList = mock(DOMTokenList.class);
    element2.classList = mock(DOMTokenList.class);
    elements.length = 2;
    doReturn(element1).when(elements).getAt(0);
    doReturn(element2).when(elements).getAt(1);
    doReturn(elements).when(helper).querySelectorAll("." + HIGHLIGHT);
    helper.cleanHighlightClass();
    verify(element1.classList).remove(HIGHLIGHT);
    verify(element2.classList).remove(HIGHLIGHT);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) Test(org.junit.Test)

Example 35 with NodeList

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

the class DataTypeListViewTest method testShowArrowIconIfDataTypeHasChildrenWhenDataTypeHasChildren.

@Test
public void testShowArrowIconIfDataTypeHasChildrenWhenDataTypeHasChildren() {
    final DataType dataType = mock(DataType.class);
    final NodeList<Element> elementNodeList = new NodeList<>();
    final Element dataTypeRow = mock(Element.class);
    final Element dataTypeRowArrow = mock(Element.class);
    final DOMTokenList arrowClassList = mock(DOMTokenList.class);
    final String uuid = "uuid";
    dataTypeRowArrow.classList = arrowClassList;
    elementNodeList.length = 1;
    when(dataType.getUUID()).thenReturn(uuid);
    when(listItems.querySelectorAll("[" + PARENT_UUID_ATTR + "=\"uuid\"]")).thenReturn(elementNodeList);
    when(listItems.querySelector("[" + UUID_ATTR + "=\"uuid\"]")).thenReturn(dataTypeRow);
    when(dataTypeRow.querySelector(ARROW_BUTTON_SELECTOR)).thenReturn(dataTypeRowArrow);
    view.showArrowIconIfDataTypeHasChildren(dataType);
    verify(arrowClassList).remove(HIDDEN_CSS_CLASS);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) Element(elemental2.dom.Element) HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) NodeList(elemental2.dom.NodeList) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) 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