Move necessary mocking out of before hooks

This commit is contained in:
Philipp Muens 2016-05-12 18:53:18 +02:00
parent a28b6b94fd
commit ce3b2f06ec

View File

@ -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);
});