mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-19 01:24:18 +00:00
* @uppy/react: propagate prop mutation Fixes: https://github.com/transloadit/uppy/issues/3203 * fixup! @uppy/react: propagate prop mutation * fixup! @uppy/react: propagate prop mutation * Apply changes to other Components * Update TODOs
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
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()
|
|
})
|
|
})
|