How to use the react-dnd-test-utils.getBackendFromInstance function in react-dnd-test-utils

To help you get started, we’ve selected a few react-dnd-test-utils 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 react-dnd / react-dnd / packages / examples / src / 01-dustbin / single-target / __tests__ / single-target-integration.spec.tsx View on Github external
it('can simulate a full drag and drop interaction', () => {
		function TestCase() {
			return 
		}
		const WrappedTestCase = wrapInTestContext(TestCase)

		// Render with the test context that uses the test backend
		const root = mount()

		// Obtain a reference to the backend
		const backend = getBackendFromInstance(root.instance() as any)

		// Find the drag source ID and use it to simulate the dragging operation
		const box: DndComponent = root
			.find(Box)
			.at(0)
			.instance() as any
		const dustbin: DndComponent = root
			.find(Dustbin)
			.instance() as any

		window.alert = jest.fn()
		simulateDragDropSequence(box, dustbin, backend)
		expect(window.alert).toHaveBeenCalledWith(
			`You dropped ${box.props.name} into Dustbin!`,
		)
	})

react-dnd-test-utils

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis

Similar packages