react-dnd#DragDropContextProvider JavaScript Examples

The following examples show how to use react-dnd#DragDropContextProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Draggable.spec.js    From wix-style-react with MIT License 5 votes vote down vote up
describe('Draggable', () => {
  // TODO: fix or remove tests if not relevant
  // eslint-disable-next-line jest/no-disabled-tests
  xit('is draggable', async () => {
    const dataHook = 'draggable-content';
    const render = ({ isPlaceholder }) =>
      isPlaceholder ? <div data-hook={dataHook} /> : null;

    render.propTypes = {
      isPlaceholder: PropTypes.bool,
    };

    const props = {
      render,
      id: '1',
      dataHook: 'draggable',
    };

    const wrapper = mount(
      <DragDropContextProvider backend={TestBackend}>
        <DraggableSource {...props} />
      </DragDropContextProvider>,
    );

    const testkit = enzymeDraggableTestkitFactory({
      dataHook: 'draggable',
      wrapper,
    });

    console.info(wrapper.instance());

    const backend = wrapper
      .instance()
      .getManager()
      .getBackend();

    const draggable = wrapper.find(DraggableSource);
    const handleId = draggable.instance().getHandlerId();

    backend.simulateBeginDrag([handleId]);

    expect(testkit.childByHook(dataHook)).not.toBeNull;
  });
});