12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- const h = require('react').createElement
- const { mount, configure } = require('enzyme')
- const ReactAdapter = require('enzyme-adapter-react-16')
- const Uppy = require('@uppy/core')
- beforeAll(() => {
- configure({ adapter: new ReactAdapter() })
- })
- jest.mock('@uppy/progress-bar', () => require('./__mocks__/ProgressBarPlugin'))
- const ProgressBar = require('./ProgressBar')
- describe('react <ProgressBar />', () => {
- it('can be mounted and unmounted', () => {
- const oninstall = jest.fn()
- const onuninstall = jest.fn()
- const uppy = new Uppy()
- const dash = mount((
- <ProgressBar
- uppy={uppy}
- onInstall={oninstall}
- onUninstall={onuninstall}
- />
- ))
- expect(oninstall).toHaveBeenCalled()
- expect(onuninstall).not.toHaveBeenCalled()
- dash.unmount()
- expect(oninstall).toHaveBeenCalled()
- expect(onuninstall).toHaveBeenCalled()
- })
- it('react on HTMLDivElement props update', async () => {
- const uppy = new Uppy()
- const dash = mount((
- <ProgressBar
- uppy={uppy}
- onInstall={Function.prototype}
- onUninstall={Function.prototype}
- hidden
- />
- ))
- expect(dash.getDOMNode().hidden).toBeTruthy()
- dash.setProps({ hidden: false })
- expect(dash.getDOMNode().hidden).toBeFalsy()
- dash.unmount()
- })
- })
|