From ce3b2f06ec376df49188aefcde9daf0dcefa8f66 Mon Sep 17 00:00:00 2001 From: Philipp Muens Date: Thu, 12 May 2016 18:53:18 +0200 Subject: [PATCH] Move necessary mocking out of before hooks --- tests/tests/classes/Plugin.js | 69 ++++++++++++++--------------------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/tests/tests/classes/Plugin.js b/tests/tests/classes/Plugin.js index bacefad23..238e204d6 100644 --- a/tests/tests/classes/Plugin.js +++ b/tests/tests/classes/Plugin.js @@ -39,41 +39,34 @@ describe('Plugin class', () => { describe('Add action', () => { - before((done) => { - const actionMock = () => { return { foo: 'bar' }; }; - const actionMockConfig = { - handler: 'actionMock', - context: 'action', - contextAction: 'mock', - options: [ - { - option: 'mockOption', - shortcut: 'm', - description: 'Mock option', - }, - ], - parameters: [ - { - parameter: 'mockParam', - description: 'Mock param', - position: '0->', - }, - ], - }; - const actionMockConfigSimple = { - handler: 'actionMock', - context: 'action2', - contextAction: 'mock', - }; + const actionMock = () => { return { foo: 'bar' }; }; + const actionMockConfig = { + handler: 'actionMock', + context: 'action', + contextAction: 'mock', + options: [ + { + option: 'mockOption', + shortcut: 'm', + description: 'Mock option', + }, + ], + parameters: [ + { + parameter: 'mockParam', + description: 'Mock param', + position: '0->', + }, + ], + }; + const actionMockConfigSimple = { + handler: 'actionMock', + context: 'action2', + contextAction: 'mock', + }; - SPlugin.addAction(actionMock, actionMockConfig); - SPlugin.addAction(actionMock, actionMockConfigSimple); - done(); - }); - - after((done) => { - done(); - }); + SPlugin.addAction(actionMock, actionMockConfig); + SPlugin.addAction(actionMock, actionMockConfigSimple); it('should have an empty options property when adding an action', () => { expect(serverless.commands.action2.mock.options.length).to.equal(0); @@ -174,10 +167,6 @@ describe('Plugin class', () => { done(); }); - after((done) => { - done(); - }); - it('should have a specified preHooks array when adding a pre hook', () => { expect(serverless.hooks.actionMockPre.length).to.equal(1); }); @@ -206,10 +195,6 @@ describe('Plugin class', () => { done(); }); - after((done) => { - done(); - }); - it('should have a specified postHooks array when adding a post hook', () => { expect(serverless.hooks.actionMockPost.length).to.equal(1); });