use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testSetupDragAreaHandlers.
@Test
public void testSetupDragAreaHandlers() {
final Event event = mock(Event.class);
doNothing().when(view).onStartDrag(any());
doNothing().when(view).onDrag(any());
doNothing().when(view).onDrop();
dragArea.onmousedown.onInvoke(event);
dragArea.onmousemove.onInvoke(event);
dragArea.onmouseup.onInvoke(event);
dragArea.onmouseout.onInvoke(event);
final InOrder inOrder = Mockito.inOrder(view);
inOrder.verify(view).onStartDrag(event);
inOrder.verify(view).onDrag(event);
inOrder.verify(view, times(2)).onDrop();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testUpdateDraggingElementYWhenDraggingYPositionIsGreaterThanMin.
@Test
public void testUpdateDraggingElementYWhenDraggingYPositionIsGreaterThanMin() {
final Event event = mock(Event.class);
final HTMLElement draggingElement = mock(HTMLElement.class);
final HTMLElement siblingElement = mock(HTMLElement.class);
final HTMLElement getDependentElement0 = mock(HTMLElement.class);
final HTMLElement getDependentElement1 = mock(HTMLElement.class);
final HTMLElement getDependentElement2 = mock(HTMLElement.class);
final List<HTMLElement> dependentElements = asList(getDependentElement0, getDependentElement1, getDependentElement2);
final int newDraggingYPosition = 10;
draggingElement.offsetTop = 30;
draggingElement.style = mock(CSSStyleDeclaration.class);
when(draggingElement.getAttribute(DATA_Y_POSITION)).thenReturn("2");
when(presenter.getItemHeight()).thenReturn(50);
when(dragArea.querySelector(".kie-dnd-draggable[data-y-position=\"1\"]")).thenReturn(siblingElement);
doNothing().when(view).clearHover();
doNothing().when(view).refreshItemsPosition();
doReturn(draggingElement).when(view).getDragging();
doReturn(newDraggingYPosition).when(view).getNewDraggingYPosition(event);
doReturn(dependentElements).when(view).getDependentElements();
view.updateDraggingElementY(event);
// update dragging element y
verify(siblingElement).setAttribute(DATA_Y_POSITION, 5);
verify(draggingElement).setAttribute(DATA_Y_POSITION, 1);
verify(getDependentElement0).setAttribute(DATA_Y_POSITION, 2);
verify(getDependentElement1).setAttribute(DATA_Y_POSITION, 3);
verify(getDependentElement2).setAttribute(DATA_Y_POSITION, 4);
verify(view).clearHover();
verify(view).refreshItemsPosition();
// set CSS top
verify(draggingElement.style).setProperty("top", "10px");
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testUpdateDraggingElementX.
@Test
public void testUpdateDraggingElementX() {
final MouseEvent event = mock(MouseEvent.class);
final HTMLElement draggingElement = mock(HTMLElement.class);
final DOMRect rect = mock(DOMRect.class);
event.x = 100;
rect.left = 25;
draggingElement.style = mock(CSSStyleDeclaration.class);
dragArea.offsetWidth = 300;
when(presenter.getIndentationSize()).thenReturn(50);
when(dragArea.getBoundingClientRect()).thenReturn(rect);
doReturn(draggingElement).when(view).getDragging();
view.updateDraggingElementX(event);
verify(draggingElement.style).setProperty("width", "calc(100% - 65px)");
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testUpdateDraggingElementXWhenNewDraggingXPositionIsLessThanZero.
@Test
public void testUpdateDraggingElementXWhenNewDraggingXPositionIsLessThanZero() {
final MouseEvent event = mock(MouseEvent.class);
final HTMLElement draggingElement = mock(HTMLElement.class);
final DOMRect rect = mock(DOMRect.class);
event.x = -1000;
rect.left = 25;
draggingElement.style = mock(CSSStyleDeclaration.class);
dragArea.offsetWidth = 300;
when(presenter.getIndentationSize()).thenReturn(50);
when(dragArea.getBoundingClientRect()).thenReturn(rect);
doReturn(draggingElement).when(view).getDragging();
view.updateDraggingElementX(event);
verify(draggingElement.style).setProperty("width", "calc(100% - 0px)");
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DataTypeListViewTest method testOnReadOnlyMessageCloseButtonClick.
@Test
public void testOnReadOnlyMessageCloseButtonClick() {
final ClickEvent event = mock(ClickEvent.class);
readOnlyMessage.classList = mock(DOMTokenList.class);
view.onReadOnlyMessageCloseButtonClick(event);
verify(readOnlyMessage.classList).add(HIDDEN_CSS_CLASS);
}
Aggregations