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