-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes #715
- Loading branch information
1 parent
b939e9a
commit 48e0d84
Showing
4 changed files
with
41 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// @flow | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import App from './app'; | ||
import DragDropContext from '../../../../src/view/drag-drop-context'; | ||
|
||
it('should not throw when unmounting', () => { | ||
const wrapper = mount( | ||
<DragDropContext onDragEnd={() => {}}> | ||
<App /> | ||
</DragDropContext>, | ||
); | ||
|
||
expect(() => wrapper.unmount()).not.toThrow(); | ||
}); | ||
|
||
it('should clean up any window event handlers', () => { | ||
jest.spyOn(window, 'addEventListener'); | ||
jest.spyOn(window, 'removeEventListener'); | ||
|
||
const wrapper = mount( | ||
<DragDropContext onDragEnd={() => {}}> | ||
<App /> | ||
</DragDropContext>, | ||
); | ||
|
||
wrapper.unmount(); | ||
|
||
expect(window.addEventListener.mock.calls).toHaveLength( | ||
window.removeEventListener.mock.calls.length, | ||
); | ||
// validation | ||
expect(window.addEventListener).toHaveBeenCalled(); | ||
expect(window.removeEventListener).toHaveBeenCalled(); | ||
}); |