How to use the react-dnd-test-utils.simulateDragDropSequence 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
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!`,
		)
	})
})
github react-dnd / react-dnd / packages / documentation / examples-decorators / src / 01-dustbin / multiple-targets / __tests__ / multiple-target-integration.spec.tsx View on Github external
// interactions

		// drop bottle into glass bin
		simulateDragDropSequence(bottleBox, glassBin, backend)
		expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name)

		// food won't drop into the glass bin
		simulateDragDropSequence(bananaBox, glassBin, backend)
		expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name)

		// glass won't drop into the food box...
		simulateDragDropSequence(bottleBox, foodBin, backend)
		expect(foodBin.props.lastDroppedItem).toBeNull()

		// but some food will work
		simulateDragDropSequence(bananaBox, foodBin, backend)
		expect(foodBin.props.lastDroppedItem.name).toEqual(bananaBox.props.name)
	})
})
github react-dnd / react-dnd / packages / documentation / examples-decorators / src / 01-dustbin / multiple-targets / __tests__ / multiple-target-integration.spec.tsx View on Github external
const bottleBox: DndC = boxes.at(0).instance() as any
		const bananaBox: DndC = boxes.at(1).instance() as any
		// const magazineBox: DndC = boxes.at(2).instance() as any

		// interactions

		// drop bottle into glass bin
		simulateDragDropSequence(bottleBox, glassBin, backend)
		expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name)

		// food won't drop into the glass bin
		simulateDragDropSequence(bananaBox, glassBin, backend)
		expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name)

		// glass won't drop into the food box...
		simulateDragDropSequence(bottleBox, foodBin, backend)
		expect(foodBin.props.lastDroppedItem).toBeNull()

		// but some food will work
		simulateDragDropSequence(bananaBox, foodBin, backend)
		expect(foodBin.props.lastDroppedItem.name).toEqual(bananaBox.props.name)
	})
})
github react-dnd / react-dnd / packages / documentation / examples-decorators / src / 01-dustbin / multiple-targets / __tests__ / multiple-target-integration.spec.tsx View on Github external
// 	.instance() as any
		// const paperFileBin: DndC = dustbins.at(3).instance() as any

		// Box Types
		const bottleBox: DndC = boxes.at(0).instance() as any
		const bananaBox: DndC = boxes.at(1).instance() as any
		// const magazineBox: DndC = boxes.at(2).instance() as any

		// interactions

		// drop bottle into glass bin
		simulateDragDropSequence(bottleBox, glassBin, backend)
		expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name)

		// food won't drop into the glass bin
		simulateDragDropSequence(bananaBox, glassBin, backend)
		expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name)

		// glass won't drop into the food box...
		simulateDragDropSequence(bottleBox, foodBin, backend)
		expect(foodBin.props.lastDroppedItem).toBeNull()

		// but some food will work
		simulateDragDropSequence(bananaBox, foodBin, backend)
		expect(foodBin.props.lastDroppedItem.name).toEqual(bananaBox.props.name)
	})
})
github react-dnd / react-dnd / packages / documentation / examples-decorators / src / 01-dustbin / multiple-targets / __tests__ / multiple-target-integration.spec.tsx View on Github external
const glassBin: DndC = dustbins.at(0).instance() as any
		const foodBin: DndC = dustbins.at(1).instance() as any
		// const paperGlassUrlBin: DndC = dustbins
		// 	.at(2)
		// 	.instance() as any
		// const paperFileBin: DndC = dustbins.at(3).instance() as any

		// Box Types
		const bottleBox: DndC = boxes.at(0).instance() as any
		const bananaBox: DndC = boxes.at(1).instance() as any
		// const magazineBox: DndC = boxes.at(2).instance() as any

		// interactions

		// drop bottle into glass bin
		simulateDragDropSequence(bottleBox, glassBin, backend)
		expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name)

		// food won't drop into the glass bin
		simulateDragDropSequence(bananaBox, glassBin, backend)
		expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name)

		// glass won't drop into the food box...
		simulateDragDropSequence(bottleBox, foodBin, backend)
		expect(foodBin.props.lastDroppedItem).toBeNull()

		// but some food will work
		simulateDragDropSequence(bananaBox, foodBin, backend)
		expect(foodBin.props.lastDroppedItem.name).toEqual(bananaBox.props.name)
	})
})

react-dnd-test-utils

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis

Similar packages