use of elemental2.dom.HTMLDocument in project kie-wb-common by kiegroup.
the class PrintHelperTest method testPrint.
@Test
public void testPrint() {
final HTMLElement element = mock(HTMLElement.class);
final HTMLDocument printDocument = mock(HTMLDocument.class);
final Window globalWindow = mock(Window.class);
final Window printWindow = mock(Window.class);
doReturn(globalWindow).when(helper).getGlobalWindow();
doReturn(printDocument).when(helper).getWindowDocument(printWindow);
doNothing().when(helper).writeElementIntoDocument(any(), any());
doNothing().when(helper).changeMediaAttributesToAll(any());
doNothing().when(helper).copyStylesFromWindow(any(), any());
doNothing().when(helper).setupPrintCommandOnPageLoad(any(), any());
when(globalWindow.open("", "_blank")).thenReturn(printWindow);
helper.print(element);
verify(helper).writeElementIntoDocument(element, printDocument);
verify(helper).changeMediaAttributesToAll(printDocument);
verify(helper).copyStylesFromWindow(printDocument, globalWindow);
verify(helper).setupPrintCommandOnPageLoad(printDocument, printWindow);
}
use of elemental2.dom.HTMLDocument in project kie-wb-common by kiegroup.
the class PrintHelperTest method testSetupPrintCommandOnPageLoad.
@Test
public void testSetupPrintCommandOnPageLoad() {
final HTMLDocument document = mock(HTMLDocument.class);
final Window window = mock(Window.class);
document.body = mock(HTMLBodyElement.class);
doNothing().when(helper).setTimeout(any(), anyInt());
helper.setupPrintCommandOnPageLoad(document, window);
document.body.onload.onInvoke(mock(Event.class));
verify(helper).setTimeout(commandArgumentCaptor.capture(), eq(10));
commandArgumentCaptor.getValue().execute();
verify(window).focus();
verify(window).print();
verify(window).close();
}
use of elemental2.dom.HTMLDocument in project kie-wb-common by kiegroup.
the class PrintHelperTest method testWriteElementIntoDocument.
@Test
public void testWriteElementIntoDocument() {
final HTMLElement element = mock(HTMLElement.class);
final HTMLDocument document = mock(HTMLDocument.class);
final HTMLBodyElement body = mock(HTMLBodyElement.class);
final String elementHTML = "<html />";
final DOMTokenList classList = mock(DOMTokenList.class);
element.innerHTML = elementHTML;
document.body = body;
body.classList = classList;
helper.writeElementIntoDocument(element, document);
verify(document).open();
verify(document).write(elementHTML);
verify(document).close();
verify(classList).add(PREVIEW_SCREEN_CSS_CLASS);
}
use of elemental2.dom.HTMLDocument in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testCreateItem.
@Test
public void testCreateItem() {
final HTMLDocument document = mock(HTMLDocument.class);
final HTMLElement expectedItem = mock(HTMLElement.class);
final HTMLElement htmlElement = mock(HTMLElement.class);
final HTMLElement grip = mock(HTMLElement.class);
final HTMLElement i0 = mock(HTMLElement.class);
final HTMLElement i1 = mock(HTMLElement.class);
DNDListDOMHelper.Factory.DOCUMENT = document;
expectedItem.classList = mock(DOMTokenList.class);
grip.classList = mock(DOMTokenList.class);
i0.classList = mock(DOMTokenList.class);
i1.classList = mock(DOMTokenList.class);
when(document.createElement("div")).thenReturn(expectedItem, grip);
when(document.createElement("i")).thenReturn(i0, i1);
final HTMLElement actualItem = view.createItem(htmlElement);
verify(actualItem).appendChild(grip);
verify(actualItem).appendChild(htmlElement);
verify(actualItem.classList).add(DRAGGABLE);
assertEquals(expectedItem, actualItem);
}
use of elemental2.dom.HTMLDocument in project kie-wb-common by kiegroup.
the class DNDListDOMHelperTest method testCreateGripElement.
@Test
public void testCreateGripElement() {
final HTMLDocument document = mock(HTMLDocument.class);
final HTMLElement expectedGrip = mock(HTMLElement.class);
final HTMLElement firstI = mock(HTMLElement.class);
final HTMLElement secondI = mock(HTMLElement.class);
final String div = "div";
final String i = "i";
DNDListDOMHelper.Factory.DOCUMENT = document;
expectedGrip.classList = mock(DOMTokenList.class);
firstI.classList = mock(DOMTokenList.class);
secondI.classList = mock(DOMTokenList.class);
when(document.createElement(div)).thenReturn(expectedGrip);
when(document.createElement(i)).thenReturn(firstI, secondI);
final HTMLElement actualGrip = createGripElement();
verify(expectedGrip).appendChild(firstI);
verify(expectedGrip).appendChild(secondI);
verify(expectedGrip.classList).add(GRIP);
verify(firstI.classList).add(ICON_CLASS);
verify(secondI.classList).add(ICON_CLASS);
verify(firstI.classList).add(ELLIPSIS_CLASS);
verify(secondI.classList).add(ELLIPSIS_CLASS);
assertEquals(expectedGrip, actualGrip);
}
Aggregations