From 4a62f6eda798b33c9fe0e15c9644801b6b2fe1c4 Mon Sep 17 00:00:00 2001 From: Jack Reed <phillipjreed@gmail.com> Date: Fri, 11 Jan 2019 09:26:57 -0700 Subject: [PATCH] add tests for componentPlugins --- __tests__/src/lib/componentPlugins.test.js | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 __tests__/src/lib/componentPlugins.test.js diff --git a/__tests__/src/lib/componentPlugins.test.js b/__tests__/src/lib/componentPlugins.test.js new file mode 100644 index 000000000..dde13deb4 --- /dev/null +++ b/__tests__/src/lib/componentPlugins.test.js @@ -0,0 +1,30 @@ +import componentPlugins from '../../../src/lib/componentPlugins'; + +describe('componentPlugins', () => { + const originalMirador = window.Mirador; + beforeAll(() => { + window.Mirador = { + plugins: { + fooPlugin: { + name: 'fooPlugin', + parent: 'FooComponent', + }, + barPlugin: { + name: 'barPlugin', + parent: 'FooComponent', + }, + }, + }; + }); + afterAll(() => { + window.Mirador = originalMirador; + }); + it('only selects plugins that are defined in config', () => { + expect(componentPlugins('FooComponent', ['barPlugin'])[0].name).toEqual('barPlugin'); + expect(componentPlugins('FooComponent', ['barPlugin']).length).toEqual(1); + }); + it('only selects plugins that define component as parent', () => { + expect(componentPlugins('BarComponent', ['barPlugin'])).toEqual([]); + expect(componentPlugins('FooComponent', ['fooPlugin']).length).toEqual(1); + }); +}); -- GitLab