Created
February 11, 2026 19:00
-
-
Save claudiainbytes/d2cbb87bdb0a9a5a5be891246e5bb7bb to your computer and use it in GitHub Desktop.
Testing Drag and Drop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { fireEvent } from '@testing-library/react' | |
| it('permite drag and drop de items', async () => { | |
| const user = userEvent.setup() | |
| render(<DraggableList />) | |
| const item1 = screen.getByText('Item 1') | |
| const item2 = screen.getByText('Item 2') | |
| // Simular drag and drop | |
| fireEvent.dragStart(item1) | |
| fireEvent.dragEnter(item2) | |
| fireEvent.dragOver(item2) | |
| fireEvent.drop(item2) | |
| fireEvent.dragEnd(item1) | |
| // Verificar nuevo orden | |
| const items = screen.getAllByRole('listitem') | |
| expect(items[0]).toHaveTextContent('Item 2') | |
| expect(items[1]).toHaveTextContent('Item 1') | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment