uppy/packages/@uppy/core/src/Plugin.test.js
Renée Kooi 013eed33f9
Fix setPluginState
I broke this in the object rest spread PR. I noticed the Dashboard was
throwing errors when trying to access `pluginState.target.filter()`.
Added a bunch of tests + fixed that method!
2018-07-19 13:02:23 +02:00

25 lines
704 B
JavaScript

const Plugin = require('./Plugin')
const Core = require('./index')
describe('Plugin', () => {
describe('getPluginState', () => {
it('returns an empty object if no state is available', () => {
class Example extends Plugin {}
const inst = new Example(new Core(), {})
expect(inst.getPluginState()).toEqual({})
})
})
describe('setPluginState', () => {
it('applies patches', () => {
class Example extends Plugin {}
const inst = new Example(new Core(), {})
inst.setPluginState({ a: 1 })
expect(inst.getPluginState()).toEqual({ a: 1 })
inst.setPluginState({ b: 2 })
expect(inst.getPluginState()).toEqual({ a: 1, b: 2 })
})
})
})