UNPKG

704 BJavaScriptView Raw
1const Plugin = require('./Plugin')
2const Core = require('./index')
3
4describe('Plugin', () => {
5 describe('getPluginState', () => {
6 it('returns an empty object if no state is available', () => {
7 class Example extends Plugin {}
8 const inst = new Example(new Core(), {})
9
10 expect(inst.getPluginState()).toEqual({})
11 })
12 })
13
14 describe('setPluginState', () => {
15 it('applies patches', () => {
16 class Example extends Plugin {}
17 const inst = new Example(new Core(), {})
18
19 inst.setPluginState({ a: 1 })
20 expect(inst.getPluginState()).toEqual({ a: 1 })
21 inst.setPluginState({ b: 2 })
22 expect(inst.getPluginState()).toEqual({ a: 1, b: 2 })
23 })
24 })
25})