mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-26 03:35:19 +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
61 lines
1.4 KiB
JavaScript
61 lines
1.4 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() })
|
|
})
|
|
|
|
const useUppy = require('./useUppy')
|
|
|
|
describe('useUppy()', () => {
|
|
it('is created and deleted according to component lifecycle', () => {
|
|
const oninstall = jest.fn()
|
|
const onuninstall = jest.fn()
|
|
|
|
function JustInstance () {
|
|
const uppy = useUppy(() => {
|
|
oninstall()
|
|
return new Uppy()
|
|
.on('cancel-all', onuninstall)
|
|
})
|
|
|
|
return <div x={uppy} />
|
|
}
|
|
|
|
const el = mount(<JustInstance />)
|
|
|
|
expect(oninstall).toHaveBeenCalled()
|
|
expect(onuninstall).not.toHaveBeenCalled()
|
|
|
|
el.unmount()
|
|
|
|
expect(oninstall).toHaveBeenCalled()
|
|
expect(onuninstall).toHaveBeenCalled()
|
|
})
|
|
|
|
it('checks types', () => {
|
|
function NullUppy () {
|
|
const uppy = useUppy(() => null)
|
|
|
|
return <div x={uppy} />
|
|
}
|
|
|
|
expect(() => {
|
|
mount(<NullUppy />)
|
|
}).toThrow('factory function must return an Uppy instance')
|
|
|
|
function GarbageUppy () {
|
|
const uppy = useUppy(() => ({
|
|
garbage: 'lala',
|
|
}))
|
|
|
|
return <div x={uppy} />
|
|
}
|
|
|
|
expect(() => {
|
|
mount(<GarbageUppy />)
|
|
}).toThrow('factory function must return an Uppy instance')
|
|
})
|
|
})
|