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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations