From 64db4a65584a1f55e8e3474f0fb3ebf2f559195f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Maa=C3=9F?= <mathias.maass@uni-leipzig.de> Date: Fri, 22 Mar 2019 13:31:41 +0100 Subject: [PATCH] remove meaningless file --- __tests__/src/extend/withPlugins.js | 110 ---------------------------- 1 file changed, 110 deletions(-) delete mode 100644 __tests__/src/extend/withPlugins.js diff --git a/__tests__/src/extend/withPlugins.js b/__tests__/src/extend/withPlugins.js deleted file mode 100644 index 0980c5de7..000000000 --- a/__tests__/src/extend/withPlugins.js +++ /dev/null @@ -1,110 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; -import { withPlugins } from '../../../src/extend'; -import { pluginStore } from '../../../src/extend/pluginStore'; - - -jest.mock('../../../src/extend/pluginStore'); - -/** */ -const Target = props => <div>Hello</div>; - -/** create wrapper */ -function createWrapper(plugins) { - pluginStore.getPlugins = () => plugins; - const props = { - bar: 2, - foo: 1, - }; - const PluginWrapper = withPlugins('Target', Target); - return shallow(<PluginWrapper {...props} />); -} - -describe('withPlugins', () => { - it('should return a function (normal function call)', () => { - expect(withPlugins('Target', Target)).toBeInstanceOf(Function); - }); - - it('should return a function (curry function call)', () => { - expect(withPlugins('Target')(Target)).toBeInstanceOf(Function); - }); - - it('displayName prop of returned function is based on target name argument', () => { - expect(withPlugins('Bubu', Target).displayName) - .toBe('WithPlugins(Bubu)'); - }); -}); - -describe('PluginHoc: if no plugin exists for the target', () => { - it('renders the target component', () => { - const wrapper = createWrapper([]); - expect(wrapper.find(Target).length).toBe(1); - expect(wrapper.find(Target).props().foo).toBe(1); - expect(wrapper.find(Target).props().bar).toBe(2); - }); -}); - -describe('PluginHoc: if a delete plugin exists for the target', () => { - it('renders nothing', () => { - const plugin = { - mode: 'delete', - target: 'Target', - }; - const wrapper = createWrapper([plugin]); - expect(wrapper.find('*').length).toBe(0); - }); -}); - -describe('PluginHoc: if a replace plugin exists for the target', () => { - it('renders the plugin component', () => { - /** */ - const PluginComponent = props => <div>look i am a plugin</div>; - const plugin = { - component: PluginComponent, - mode: 'replace', - target: 'Target', - }; - const wrapper = createWrapper([plugin]); - const selector = 'Connect(PluginComponent)'; - expect(wrapper.find(selector).length).toBe(1); - expect(wrapper.find(selector).props().foo).toBe(1); - expect(wrapper.find(selector).props().bar).toBe(2); - }); -}); - -describe('PluginHoc: if a add plugin exists for the target', () => { - it('renders the target component and passes the plugin component as a prop', () => { - /** */ - const PluginComponent = props => <div>look i am a plugin</div>; - const plugin = { - component: PluginComponent, - mode: 'add', - target: 'Target', - }; - const wrapper = createWrapper([plugin]); - expect(wrapper.find(Target).length).toBe(1); - expect(wrapper.find(Target).props().foo).toBe(1); - expect(wrapper.find(Target).props().bar).toBe(2); - expect(wrapper.find(Target).props().PluginComponent.WrappedComponent) - .toBe(PluginComponent); - }); -}); - -describe('PluginHoc: if a wrap plugin extists for the target', () => { - it('renders the plugin component and passes the target component as a prop', () => { - /** */ - const PluginComponent = props => <div>look i am a plugin</div>; - const plugin = { - component: PluginComponent, - mode: 'wrap', - target: 'Target', - }; - const wrapper = createWrapper([plugin]); - const selector = 'Connect(PluginComponent)'; - expect(wrapper.find(selector).length).toBe(1); - expect(wrapper.find(selector).props().foo).toBe(1); - expect(wrapper.find(selector).props().bar).toBe(2); - expect(wrapper.find(selector).props().TargetComponent) - .toBe(Target); - }); -}); -- GitLab