use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.
the class DragAndDropHelperTest method testRefreshItemsPosition.
@Test
public void testRefreshItemsPosition() {
final HTMLElement element1 = mock(HTMLElement.class);
final HTMLElement element2 = mock(HTMLElement.class);
final HTMLElement element3 = mock(HTMLElement.class);
final CSSStyleDeclaration element1Style = mock(CSSStyleDeclaration.class);
final CSSStyleDeclaration element2Style = mock(CSSStyleDeclaration.class);
final CSSStyleDeclaration element3Style = mock(CSSStyleDeclaration.class);
element1.style = element1Style;
element2.style = element2Style;
element3.style = element3Style;
element1.offsetHeight = 50;
final NodeList<Element> draggableItems = spy(new NodeList<>());
doReturn(element1).when(draggableItems).getAt(0);
doReturn(element2).when(draggableItems).getAt(1);
doReturn(element3).when(draggableItems).getAt(2);
when(element1.getAttribute(DATA_POSITION)).thenReturn("0");
when(element2.getAttribute(DATA_POSITION)).thenReturn("1");
when(element3.getAttribute(DATA_POSITION)).thenReturn("2");
draggableItems.length = 3;
when(dragArea.querySelectorAll(DragAndDropHelper.DRAGGABLE_ITEM_CLASS)).thenReturn(draggableItems);
helper.refreshItemsPosition();
verify(element1Style).setProperty(TOP, 0 + PX);
verify(element2Style).setProperty(TOP, 50 + PX);
verify(element3Style).setProperty(TOP, 100 + PX);
verify(addButtonContainerStyle).setProperty(TOP, 150 + PX);
}
use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.
the class PrintHelperTest method testChangeMediaAttributesToAll.
@Test
public void testChangeMediaAttributesToAll() {
final HTMLDocument document = mock(HTMLDocument.class);
final Element element = mock(Element.class);
final NodeList<Element> links = spy(new NodeList<>());
final String media = "media";
links.length = 1;
doReturn(element).when(links).item(0);
doReturn(element).when(helper).asElement(element);
when(document.querySelectorAll("link")).thenReturn(links);
when(element.getAttribute(media)).thenReturn("print");
helper.changeMediaAttributesToAll(document);
verify(element).setAttribute(media, "all");
}
use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.
the class PrintHelperTest method testCopyStylesFromWindow.
@Test
public void testCopyStylesFromWindow() {
final HTMLDocument document = mock(HTMLDocument.class);
final HTMLDocument topDocument = mock(HTMLDocument.class);
final Window window = mock(Window.class);
final Window topWindow = mock(Window.class);
final Element element = mock(Element.class);
final Element head = mock(Element.class);
final NodeList<Element> parentStyles = spy(new NodeList<>());
parentStyles.length = 1;
window.top = topWindow;
element.innerHTML = ".page { background: red }";
doReturn(element).when(parentStyles).item(0);
doReturn(topDocument).when(helper).getWindowDocument(topWindow);
doReturn(element).when(helper).asElement(element);
doReturn(head).when(helper).asElement(head);
doReturn(mock(Element.class)).when(helper).createElement("style");
when(document.querySelector("head")).thenReturn(head);
when(topDocument.querySelectorAll("style")).thenReturn(parentStyles);
helper.copyStylesFromWindow(document, window);
verify(head).appendChild(elementArgumentCaptor.capture());
final Element copiedStyle = elementArgumentCaptor.getValue();
assertEquals(".page { background: red }", copiedStyle.innerHTML);
}
use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.
the class PrintHelper method copyStylesFromWindow.
void copyStylesFromWindow(final HTMLDocument printDocument, final Window window) {
final HTMLDocument topDocument = getWindowDocument(window.top);
final NodeList<Element> parentStyles = topDocument.querySelectorAll("style");
final Element documentHead = asElement(printDocument.querySelector("head"));
for (int i = 0; i < parentStyles.length; i++) {
final Element copiedStyle = createElement("style");
copiedStyle.innerHTML = asElement(parentStyles.item(i)).innerHTML;
documentHead.appendChild(copiedStyle);
}
}
use of elemental2.dom.NodeList in project kie-wb-common by kiegroup.
the class DataTypeListViewTest method makeElement.
public Element makeElement(final String uuid) {
final Element element = mock(Element.class);
mockDOMElementsByParentUUID(uuid, new NodeList<>());
when(element.getAttribute(UUID_ATTR)).thenReturn(uuid);
return element;
}
Aggregations