@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); }
HTMLElement createItem(final HTMLElement htmlElement) { final HTMLElement item = Factory.createDiv(); final HTMLElement gripElement = Factory.createGripElement(); item.appendChild(gripElement); item.appendChild(htmlElement); return asDraggable(item); }
DNDListComponentView implements DNDListComponent.View { HTMLElement createItem(final HTMLElement htmlElement) { final HTMLElement item = Factory.createDiv(); final HTMLElement gripElement = Factory.createGripElement(); item.appendChild(gripElement); item.appendChild(htmlElement); return asDraggable(item); } }
DNDListComponentView implements DNDListComponent.View { HTMLElement createItem(final HTMLElement htmlElement) { final HTMLElement item = Factory.createDiv(); final HTMLElement gripElement = Factory.createGripElement(); item.appendChild(gripElement); item.appendChild(htmlElement); return asDraggable(item); } @Inject  DNDListComponentView(final HTMLDivElement dragArea); }
DNDListComponentView implements DNDListComponent.View { HTMLElement createItem(final HTMLElement htmlElement) { final HTMLElement item = Factory.createDiv(); final HTMLElement gripElement = Factory.createGripElement(); item.appendChild(gripElement); item.appendChild(htmlElement); return asDraggable(item); } @Inject  DNDListComponentView(final HTMLDivElement dragArea); @Override void init(final DNDListComponent presenter); @Override HTMLElement registerItem(final HTMLElement htmlElement); @Override void refreshItemsPosition(); @Override void refreshItemsHTML(); @Override void consolidateHierarchicalLevel(final boolean isElementsDraggedByUser); @Override void consolidateYPosition(); @Override void clear(); @Override Optional<HTMLElement> getPreviousElement(final Element reference); @Override void refreshDragAreaSize(); @Override HTMLDivElement getDragArea(); }
DNDListComponentView implements DNDListComponent.View { HTMLElement createItem(final HTMLElement htmlElement) { final HTMLElement item = Factory.createDiv(); final HTMLElement gripElement = Factory.createGripElement(); item.appendChild(gripElement); item.appendChild(htmlElement); return asDraggable(item); } @Inject  DNDListComponentView(final HTMLDivElement dragArea); @Override void init(final DNDListComponent presenter); @Override HTMLElement registerItem(final HTMLElement htmlElement); @Override void refreshItemsPosition(); @Override void refreshItemsHTML(); @Override void consolidateHierarchicalLevel(final boolean isElementsDraggedByUser); @Override void consolidateYPosition(); @Override void clear(); @Override Optional<HTMLElement> getPreviousElement(final Element reference); @Override void refreshDragAreaSize(); @Override HTMLDivElement getDragArea();  }