mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-20 16:53:33 +00:00
* relocate .vscode
* Switch to transloadit linter
* Update .eslintrc.json
* autofix code
* unlink and install eslint-config-transloadit@1.1.1
* Change 0 to "off"
* Don't change 'use strict'
* Do not vertically align
* disable key-spacing
* add import/no-extraneous-dependencies per package
* add more react/a11y warnings
* Revert "autofix code"
This reverts commit 14c8a8cde8.
* add import/no-extraneous-dependencies per example and main package
* autofix code (2)
* Allow devDependencies in ./bin
* Change import/no-extraneous-dependencies to warn again
* upgrade linter
* Set import/no-extraneous-dependencies to warn
81 lines
1.8 KiB
JavaScript
81 lines
1.8 KiB
JavaScript
const h = require('react').createElement
|
|
const { mount, configure } = require('enzyme')
|
|
const ReactAdapter = require('enzyme-adapter-react-16')
|
|
const Uppy = require('@uppy/core')
|
|
|
|
jest.mock('@uppy/dashboard', () => require('./__mocks__/DashboardPlugin'))
|
|
|
|
const DashboardModal = require('./DashboardModal')
|
|
|
|
beforeAll(() => {
|
|
configure({ adapter: new ReactAdapter() })
|
|
})
|
|
|
|
beforeEach(() => {
|
|
Object.assign(require('@uppy/dashboard').prototype, {
|
|
openModal: jest.fn(),
|
|
closeModal: jest.fn(),
|
|
})
|
|
})
|
|
|
|
describe('react <DashboardModal />', () => {
|
|
it('can be mounted and unmounted', () => {
|
|
const oninstall = jest.fn()
|
|
const onuninstall = jest.fn()
|
|
const uppy = new Uppy()
|
|
const dash = mount((
|
|
<DashboardModal
|
|
uppy={uppy}
|
|
onInstall={oninstall}
|
|
onUninstall={onuninstall}
|
|
/>
|
|
))
|
|
|
|
expect(oninstall).toHaveBeenCalled()
|
|
expect(onuninstall).not.toHaveBeenCalled()
|
|
|
|
dash.unmount()
|
|
|
|
expect(oninstall).toHaveBeenCalled()
|
|
expect(onuninstall).toHaveBeenCalled()
|
|
})
|
|
|
|
it('opens the modal using the `open={true}` prop', () => {
|
|
const uppy = new Uppy()
|
|
const dash = mount((
|
|
<DashboardModal
|
|
uppy={uppy}
|
|
open={false}
|
|
/>
|
|
))
|
|
const { plugin } = dash.instance()
|
|
|
|
expect(plugin.openModal).not.toHaveBeenCalled()
|
|
|
|
dash.setProps({ open: true })
|
|
|
|
expect(plugin.openModal).toHaveBeenCalled()
|
|
|
|
dash.unmount()
|
|
})
|
|
|
|
it('closes the modal using the `open={false}` prop', () => {
|
|
const uppy = new Uppy()
|
|
const dash = mount((
|
|
<DashboardModal
|
|
uppy={uppy}
|
|
open
|
|
/>
|
|
))
|
|
const { plugin } = dash.instance()
|
|
|
|
expect(plugin.openModal).toHaveBeenCalled()
|
|
expect(plugin.closeModal).not.toHaveBeenCalled()
|
|
|
|
dash.setProps({ open: false })
|
|
|
|
expect(plugin.closeModal).toHaveBeenCalled()
|
|
|
|
dash.unmount()
|
|
})
|
|
})
|