use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testGetNewDraggingYPosition.
@Test
public void testGetNewDraggingYPosition() {
final MouseEvent event = mock(MouseEvent.class);
final HTMLElement draggingElement = mock(HTMLElement.class);
final DOMRect rect = mock(DOMRect.class);
event.y = 100;
rect.top = 25;
draggingElement.style = mock(CSSStyleDeclaration.class);
dragArea.offsetHeight = 300;
when(presenter.getItemHeight()).thenReturn(50);
when(dragArea.getBoundingClientRect()).thenReturn(rect);
doReturn(draggingElement).when(view).getDragging();
final int actualYPosition = view.getNewDraggingYPosition(event);
final int expectedYPosition = 50;
assertEquals(expectedYPosition, actualYPosition);
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testGetNewDraggingYPositionWhenNewYPositionIsGreaterThanMax.
@Test
public void testGetNewDraggingYPositionWhenNewYPositionIsGreaterThanMax() {
final MouseEvent event = mock(MouseEvent.class);
final HTMLElement draggingElement = mock(HTMLElement.class);
final DOMRect rect = mock(DOMRect.class);
event.y = 1000;
rect.top = 25;
draggingElement.style = mock(CSSStyleDeclaration.class);
dragArea.offsetHeight = 300;
when(presenter.getItemHeight()).thenReturn(50);
when(dragArea.getBoundingClientRect()).thenReturn(rect);
doReturn(draggingElement).when(view).getDragging();
final int actualYPosition = view.getNewDraggingYPosition(event);
final int expectedYPosition = 325;
assertEquals(expectedYPosition, actualYPosition);
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class TimeSelectorViewTest method testOnTimeInputBlurToChildrenElement.
@Test
public void testOnTimeInputBlurToChildrenElement() {
final BlurEvent event = mock(BlurEvent.class);
final Element target = mock(Element.class);
doReturn(target).when(view).getEventTarget(event);
doReturn(true).when(view).isChildOfView(target);
view.onTimeInputBlur(event);
verify(onValueInputBlur, never()).accept(event);
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testOnStartDragWhenTargetIsGrip.
@Test
public void testOnStartDragWhenTargetIsGrip() {
final Event event = mock(Event.class);
final HTMLElement parent = mock(HTMLElement.class);
final HTMLElement target = mock(HTMLElement.class);
event.target = target;
target.parentNode = parent;
target.classList = mock(DOMTokenList.class);
when(target.classList.contains(GRIP)).thenReturn(true);
doNothing().when(view).holdDraggingElement(any());
view.onStartDrag(event);
verify(view).holdDraggingElement(parent);
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DNDListComponentViewTest method testOnDragWhenUserIsDragging.
@Test
public void testOnDragWhenUserIsDragging() {
final Event event = mock(Event.class);
doReturn(false).when(view).isNotDragging();
doNothing().when(view).updateDraggingElementY(event);
doNothing().when(view).updateDraggingElementX(event);
doNothing().when(view).updateHoverElement();
doNothing().when(view).updateDependentsPosition();
view.onDrag(event);
verify(view).updateDraggingElementY(event);
verify(view).updateDraggingElementX(event);
verify(view).updateHoverElement();
verify(view).updateDependentsPosition();
}
Aggregations