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