use of elemental2.dom.MouseEvent in project kie-wb-common by kiegroup.
the class DragAndDropHelperTest method testOnDragAreaMouseDown.
@Test
public void testOnDragAreaMouseDown() {
final int clientY = 123;
final int startYPosition = 1;
final MouseEvent mouseEvent = mock(MouseEvent.class);
final Element dragGrabber = mock(Element.class);
final Element target = mock(Element.class);
final HTMLElement draggable = mock(HTMLElement.class);
mouseEvent.clientY = clientY;
mouseEvent.target = target;
when(target.closest(".drag-grabber")).thenReturn(dragGrabber);
when(dragGrabber.closest(DragAndDropHelper.DRAGGABLE_ITEM_CLASS)).thenReturn(draggable);
doReturn(startYPosition).when(helper).getTop(draggable);
helper.onDragAreaMouseDown(mouseEvent);
assertEquals(startYPosition, helper.getStartYPosition());
assertEquals(clientY, helper.getClickedYPosition());
assertEquals(draggable, helper.getDragging());
}
use of elemental2.dom.MouseEvent in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testUpdateDraggingElementXWhenNewDraggingXPositionIsGreaterThanMax.
@Test
public void testUpdateDraggingElementXWhenNewDraggingXPositionIsGreaterThanMax() {
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% - 250px)");
}
use of elemental2.dom.MouseEvent in project kie-wb-common by kiegroup.
the class DragAndDropHelperTest method testGetDelta.
@Test
public void testGetDelta() {
final int clickedYPosition = 20;
final int mousePosition = 10;
final int expected = mousePosition - clickedYPosition;
final MouseEvent mouseEvent = mock(MouseEvent.class);
mouseEvent.clientY = mousePosition;
doReturn(clickedYPosition).when(helper).getClickedYPosition();
final int actual = helper.getDelta(mouseEvent);
assertEquals(expected, actual);
}
use of elemental2.dom.MouseEvent 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.MouseEvent 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)");
}
Aggregations