Plugin.test.js 704 B

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