Search in sources :

Example 11 with NodeList

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

the class DataTypeListViewTest method testShowArrowIconIfDataTypeHasChildrenWhenDataTypeDoesNotHaveChildren.

@Test
public void testShowArrowIconIfDataTypeHasChildrenWhenDataTypeDoesNotHaveChildren() {
    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 = 0;
    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).add(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)

Example 12 with NodeList

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

the class DataTypeListViewTest method testCleanSubTypesByUUID.

@Test
public void testCleanSubTypesByUUID() {
    final String parentUUID = "parentUUID";
    final String child1UUID = "child1UUID";
    final String child2UUID = "child2UUID";
    final Element parentElement = makeHTMLElement();
    final NodeList<Element> children = spy(new NodeList<>());
    final Element child1 = makeElement(child1UUID);
    final Element child2 = makeElement(child2UUID);
    final Element child3NoParent = makeElement("child3UUID");
    final Element child4Null = null;
    child2.parentNode = parentElement;
    child1.parentNode = parentElement;
    children.length = 4;
    doReturn(child1).when(children).getAt(0);
    doReturn(child2).when(children).getAt(1);
    doReturn(child3NoParent).when(children).getAt(2);
    doReturn(child4Null).when(children).getAt(3);
    mockDOMElementsByParentUUID(parentUUID, children);
    view.cleanSubTypes(parentUUID);
    verify(presenter).removeItem(child1UUID);
    verify(presenter).removeItem(child2UUID);
    verify(parentElement).removeChild(child1);
    verify(parentElement).removeChild(child2);
    verify(parentElement, never()).removeChild(child3NoParent);
    verify(parentElement, never()).removeChild(child4Null);
}
Also used : Element(elemental2.dom.Element) HTMLAnchorElement(elemental2.dom.HTMLAnchorElement) HTMLElement(elemental2.dom.HTMLElement) HTMLDivElement(elemental2.dom.HTMLDivElement) HTMLButtonElement(elemental2.dom.HTMLButtonElement) Test(org.junit.Test)

Example 13 with NodeList

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

the class DataTypeListHighlightHelperTest method testCleanLevelHighlightClass.

@Test
public void testCleanLevelHighlightClass() {
    final Element element1 = mock(Element.class);
    final Element element2 = mock(Element.class);
    final Element backgroundLine1 = mock(Element.class);
    final Element backgroundLine2 = mock(Element.class);
    final Node parentNode = mock(Node.class);
    final NodeList<Element> highlightedElements = spy(new NodeList<>());
    final NodeList<Element> backgroundLines = spy(new NodeList<>());
    element1.classList = mock(DOMTokenList.class);
    element2.classList = mock(DOMTokenList.class);
    backgroundLine1.parentNode = parentNode;
    backgroundLine2.parentNode = parentNode;
    highlightedElements.length = 2;
    backgroundLines.length = 2;
    doReturn(element1).when(highlightedElements).getAt(0);
    doReturn(element2).when(highlightedElements).getAt(1);
    doReturn(backgroundLine1).when(backgroundLines).getAt(0);
    doReturn(backgroundLine2).when(backgroundLines).getAt(1);
    doReturn(highlightedElements).when(helper).querySelectorAll("." + LEVEL_HIGHLIGHT);
    doReturn(backgroundLines).when(helper).querySelectorAll("." + LEVEL_BACKGROUND_LINE);
    helper.cleanLevelHighlightClass();
    verify(element1.classList).remove(LEVEL_HIGHLIGHT);
    verify(element2.classList).remove(LEVEL_HIGHLIGHT);
    verify(parentNode).removeChild(backgroundLine1);
    verify(parentNode).removeChild(backgroundLine2);
}
Also used : DOMTokenList(elemental2.dom.DOMTokenList) Element(elemental2.dom.Element) HTMLElement(elemental2.dom.HTMLElement) Node(elemental2.dom.Node) Test(org.junit.Test)

Example 14 with NodeList

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

the class DataTypeListItemViewTest method testDisableFocusMode.

@Test
public void testDisableFocusMode() {
    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;
    parentElement.classList = mock(DOMTokenList.class);
    view.disableFocusMode();
    verify(parentElement.classList).remove(FOCUSED_CSS_CLASS);
    verify(child1.classList).remove(FOCUSED_CSS_CLASS);
    verify(child2.classList).remove(FOCUSED_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) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) Test(org.junit.Test)

Example 15 with NodeList

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

the class DataTypeListItemViewTest method testEnableFocusMode.

@Test
public void testEnableFocusMode() {
    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);
    doReturn(nameInput).when(view).getNameInput();
    mockDOMElementByUUID(parentDataTypeUUID, parentElement);
    mockDOMElementsByParentUUID(parentDataTypeUUID, children);
    children.length = 2;
    parentElement.classList = mock(DOMTokenList.class);
    view.enableFocusMode();
    verify(parentElement.classList).add(FOCUSED_CSS_CLASS);
    verify(child1.classList).add(FOCUSED_CSS_CLASS);
    verify(child2.classList).add(FOCUSED_CSS_CLASS);
    verify(nameInput).select();
}
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) 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