DragDrop.test.js 880 B

1234567891011121314151617181920212223242526272829303132333435
  1. const h = require('react').createElement
  2. const { mount, configure } = require('enzyme')
  3. const ReactAdapter = require('enzyme-adapter-react-16')
  4. const Uppy = require('../core')
  5. beforeAll(() => {
  6. configure({ adapter: new ReactAdapter() })
  7. })
  8. jest.mock('../plugins/DragDrop', () => require('./__mocks__/DragDropPlugin'))
  9. const DragDrop = require('./DragDrop')
  10. describe('react <DragDrop />', () => {
  11. it('can be mounted and unmounted', () => {
  12. const oninstall = jest.fn()
  13. const onuninstall = jest.fn()
  14. const uppy = Uppy()
  15. const dash = mount((
  16. <DragDrop
  17. uppy={uppy}
  18. onInstall={oninstall}
  19. onUninstall={onuninstall}
  20. />
  21. ))
  22. expect(oninstall).toHaveBeenCalled()
  23. expect(onuninstall).not.toHaveBeenCalled()
  24. dash.unmount()
  25. expect(oninstall).toHaveBeenCalled()
  26. expect(onuninstall).toHaveBeenCalled()
  27. })
  28. })