How to use the @testing-library/react.fireEvent.drop function in @testing-library/react

To help you get started, we’ve selected a few @testing-library/react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github marmelab / react-admin / packages / ra-ui-materialui / src / input / ImageInput.spec.tsx View on Github external
}}
                onSubmit={onSubmit}
                render={({ handleSubmit }) => (
                    <form>
                        
                            <div>
                        
                        <button aria-label="Save" type="submit">
                    
                )}
            /&gt;
        );

        const file1 = createFile('cats.gif', 1234, 'image/gif');
        const file2 = createFile('cats2.gif', 1234, 'image/gif');
        fireEvent.drop(
            getByTestId('dropzone'),
            createDataTransfer([file1, file2])
        );
        // Required because react-dropzone handle drag &amp; drop operations asynchronously
        await new Promise(resolve =&gt; setImmediate(resolve));

        fireEvent.click(getByLabelText('Save'));

        expect(onSubmit.mock.calls[0][0]).toEqual({
            images: [
                {
                    src: 'cats.gif',
                },
                {
                    src: 'cats2.gif',
                },</button></div></form>
github marmelab / react-admin / packages / ra-ui-materialui / src / input / FileInput.spec.tsx View on Github external
image: undefined,
                }}
                onSubmit={onSubmit}
                render={({ handleSubmit }) =&gt; (
                    <form>
                        
                            <div>
                        
                        <button aria-label="Save" type="submit">
                    
                )}
            /&gt;
        );

        const file = createFile('cats.gif', 1234, 'image/gif');
        fireEvent.drop(getByTestId('dropzone'), createDataTransfer([file]));
        // Required because react-dropzone handle drag &amp; drop operations asynchronously
        await new Promise(resolve =&gt; setImmediate(resolve));

        fireEvent.click(getByLabelText('Save'));

        expect(onSubmit.mock.calls[0][0]).toEqual({
            images: [
                {
                    src: 'cats.gif',
                },
            ],
        });
    });
</button></div></form>
github flow-typed / flow-typed / definitions / npm / @testing-library / react_v8.x.x / flow_v0.104.x- / test_react_v8.x.x.js View on Github external
fireEvent.change(htmlEl);
    fireEvent.input(htmlEl);
    fireEvent.invalid(htmlEl);
    fireEvent.submit(htmlEl);
    fireEvent.click(htmlEl);
    fireEvent.contextMenu(htmlEl);
    fireEvent.dblClick(htmlEl);
    fireEvent.doubleClick(htmlEl);
    fireEvent.drag(htmlEl);
    fireEvent.dragEnd(htmlEl);
    fireEvent.dragEnter(htmlEl);
    fireEvent.dragExit(htmlEl);
    fireEvent.dragLeave(htmlEl);
    fireEvent.dragOver(htmlEl);
    fireEvent.dragStart(htmlEl);
    fireEvent.drop(htmlEl);
    fireEvent.mouseDown(htmlEl);
    fireEvent.mouseEnter(htmlEl);
    fireEvent.mouseLeave(htmlEl);
    fireEvent.mouseMove(htmlEl);
    fireEvent.mouseOut(htmlEl);
    fireEvent.mouseOver(htmlEl);
    fireEvent.mouseUp(htmlEl);
    fireEvent.select(htmlEl);
    fireEvent.touchCancel(htmlEl);
    fireEvent.touchEnd(htmlEl);
    fireEvent.touchMove(htmlEl);
    fireEvent.touchStart(htmlEl);
    fireEvent.scroll(htmlEl);
    fireEvent.wheel(htmlEl);
    fireEvent.abort(htmlEl);
    fireEvent.canPlay(htmlEl);
github akeneo / pim-community-dev / tests / front / unit / structure / attribute-option / components / List.unit.tsx View on Github external
const setDragImage = jest.fn();
    Object.assign(dragStartEvent, {
        dataTransfer: {
            setDragImage,
        },
    });
    await fireEvent(attributeOptionMoveHandle, dragStartEvent);
    await fireEvent.dragOver(attributeOptions[1], {
        target: {
            getBoundingClientRect: jest.fn().mockImplementation(() => {
                return {bottom: 10, top: 0};
            }),
            clientY: 6
        },
    });
    await fireEvent.drop(attributeOptionMoveHandle);
    await fireEvent.dragEnd(attributeOptionMoveHandle);
}
github openfun / marsha / src / frontend / components / UploadForm / index.spec.tsx View on Github external
const { container } = render(
      wrapInIntlProvider(
        wrapInRouter(
          ,
          [
            {
              path: DASHBOARD_ROUTE(),
              render: () =&gt; <span>dashboard</span>,
            },
          ],
        ),
      ),
    );
    await screen.findByText('Create a new video');

    fireEvent.drop(container.querySelector('input[type="file"]')!, {
      target: {
        files: [new File(['(⌐□_□)'], 'course.mp4', { type: 'video/mp4' })],
      },
    });
    await waitFor(() =&gt;
      expect(
        fetchMock.called('/api/videos/video-id/initiate-upload/', {
          method: 'POST',
        }),
      ).toBe(true),
    );
    await waitFor(() =&gt;
      expect(fetchMock.called('/api/videos/video-id/', { method: 'PUT' })).toBe(
        true,
      ),
    );
github react-dropzone / react-dropzone / src / index.spec.js View on Github external
expect(rootProps.onFocus).not.toHaveBeenCalled()
      expect(rootProps.onKeyDown).not.toHaveBeenCalled()

      fireEvent.blur(dropzone)
      expect(rootProps.onBlur).not.toHaveBeenCalled()

      fireEvent.dragEnter(dropzone, event)
      expect(rootProps.onDragEnter).not.toHaveBeenCalled()

      fireEvent.dragOver(dropzone, event)
      expect(rootProps.onDragOver).not.toHaveBeenCalled()

      fireEvent.dragLeave(dropzone, event)
      expect(rootProps.onDragLeave).not.toHaveBeenCalled()

      fireEvent.drop(dropzone, event)
      expect(rootProps.onDrop).not.toHaveBeenCalled()

      const input = container.querySelector('input')

      fireEvent.click(input)
      expect(inputProps.onClick).not.toHaveBeenCalled()

      fireEvent.change(input)
      expect(inputProps.onChange).not.toHaveBeenCalled()
    })