mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Merge pull request #1184 from serverless/rename-and-refactor-existing-plugins
Rename and refactor existing plugins
This commit is contained in:
commit
35b07f33ea
@ -3,7 +3,7 @@
|
||||
'use strict';
|
||||
|
||||
// Note: TestsPlugin is only used for tests
|
||||
const TestsPlugin = require('../lib/plugins/Tests/Tests');
|
||||
const TestsPlugin = require('../lib/plugins/tests/tests');
|
||||
|
||||
let SUtils = require('../lib/classes/Utils');
|
||||
SUtils = new SUtils();
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Test: HelloWorld Plugin
|
||||
*/
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const HelloWorld = require('../HelloWorld');
|
||||
|
||||
describe('HelloWorld', () => {
|
||||
let helloWorld;
|
||||
|
||||
beforeEach(() => {
|
||||
helloWorld = new HelloWorld();
|
||||
});
|
||||
|
||||
describe('#constructor()', () => {
|
||||
it('should have commands', () => expect(helloWorld.commands).to.be.not.empty);
|
||||
|
||||
it('should have hooks', () => expect(helloWorld.hooks).to.be.not.empty);
|
||||
});
|
||||
|
||||
describe('#printGoodMorning()', () => {
|
||||
it('should print "Good morning"', () => {
|
||||
const greeting = helloWorld.printGoodMorning();
|
||||
|
||||
expect(greeting).to.equal('Good morning');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#printHello()', () => {
|
||||
it('should print "Hello"', () => {
|
||||
const greeting = helloWorld.printHello();
|
||||
|
||||
expect(greeting).to.equal('Hello');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#printGoodEvening()', () => {
|
||||
it('should print "Good evening"', () => {
|
||||
const greeting = helloWorld.printGoodEvening();
|
||||
|
||||
expect(greeting).to.equal('Good evening');
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -2,6 +2,6 @@
|
||||
"plugins": [
|
||||
"./deploy/deploy.js",
|
||||
"./create/create.js",
|
||||
"./HelloWorld/HelloWorld.js"
|
||||
"./helloWorld/helloWorld.js"
|
||||
]
|
||||
}
|
||||
|
||||
109
lib/plugins/helloWorld/tests/helloWorld.js
Normal file
109
lib/plugins/helloWorld/tests/helloWorld.js
Normal file
@ -0,0 +1,109 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Test: HelloWorld Plugin
|
||||
*/
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const HelloWorld = require('../helloWorld');
|
||||
|
||||
describe('HelloWorld', () => {
|
||||
let helloWorld;
|
||||
|
||||
beforeEach(() => {
|
||||
helloWorld = new HelloWorld();
|
||||
});
|
||||
|
||||
describe('#constructor()', () => {
|
||||
it('should have commands', () => expect(helloWorld.commands).to.be.not.empty);
|
||||
|
||||
it('should have hooks', () => expect(helloWorld.hooks).to.be.not.empty);
|
||||
});
|
||||
|
||||
describe('when gender is "female"', () => {
|
||||
describe('#printGoodMorning()', () => {
|
||||
it('should print "Good morning madam"', () => {
|
||||
const optionsMock = { gender: 'female' };
|
||||
const greeting = helloWorld.printGoodMorning(optionsMock);
|
||||
|
||||
expect(greeting).to.equal('Good morning madam');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#printHello()', () => {
|
||||
it('should print "Hello madam"', () => {
|
||||
const optionsMock = { gender: 'female' };
|
||||
const greeting = helloWorld.printHello(optionsMock);
|
||||
|
||||
expect(greeting).to.equal('Hello madam');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#printGoodEvening()', () => {
|
||||
it('should print "Good evening madam"', () => {
|
||||
const optionsMock = { gender: 'female' };
|
||||
const greeting = helloWorld.printGoodEvening(optionsMock);
|
||||
|
||||
expect(greeting).to.equal('Good evening madam');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when gender is "male"', () => {
|
||||
describe('#printGoodMorning()', () => {
|
||||
it('should print "Good morning sir"', () => {
|
||||
const optionsMock = { gender: 'male' };
|
||||
const greeting = helloWorld.printGoodMorning(optionsMock);
|
||||
|
||||
expect(greeting).to.equal('Good morning sir');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#printHello()', () => {
|
||||
it('should print "Hello sir"', () => {
|
||||
const optionsMock = { gender: 'male' };
|
||||
const greeting = helloWorld.printHello(optionsMock);
|
||||
|
||||
expect(greeting).to.equal('Hello sir');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#printGoodEvening()', () => {
|
||||
it('should print "Good evening sir"', () => {
|
||||
const optionsMock = { gender: 'male' };
|
||||
const greeting = helloWorld.printGoodEvening(optionsMock);
|
||||
|
||||
expect(greeting).to.equal('Good evening sir');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when gender is not given', () => {
|
||||
describe('#printGoodMorning()', () => {
|
||||
it('should print "Good morning madam"', () => {
|
||||
const optionsMock = { gender: '' };
|
||||
const greeting = helloWorld.printGoodMorning(optionsMock);
|
||||
|
||||
expect(greeting).to.equal('Good morning madam');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#printHello()', () => {
|
||||
it('should print "Hello madam"', () => {
|
||||
const optionsMock = { gender: '' };
|
||||
const greeting = helloWorld.printHello(optionsMock);
|
||||
|
||||
expect(greeting).to.equal('Hello madam');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#printGoodEvening()', () => {
|
||||
it('should print "Good evening madam"', () => {
|
||||
const optionsMock = { gender: '' };
|
||||
const greeting = helloWorld.printGoodEvening(optionsMock);
|
||||
|
||||
expect(greeting).to.equal('Good evening madam');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -5,12 +5,12 @@
|
||||
*/
|
||||
|
||||
const expect = require('chai').expect;
|
||||
const Tests = require('../Tests');
|
||||
const TestsPlugin = require('../Tests');
|
||||
const Tests = require('../tests');
|
||||
const TestsPlugin = require('../tests');
|
||||
const exec = require('child_process').exec;
|
||||
const path = require('path');
|
||||
|
||||
describe('Test', () => {
|
||||
describe('Tests', () => {
|
||||
let tests;
|
||||
|
||||
beforeEach(() => {
|
||||
@ -3,7 +3,7 @@
|
||||
const expect = require('chai').expect;
|
||||
const PluginManager = require('../../lib/classes/PluginManager');
|
||||
const Serverless = require('../../lib/Serverless');
|
||||
const HelloWorld = require('../../lib/plugins/HelloWorld/HelloWorld');
|
||||
const HelloWorld = require('../../lib/plugins/helloWorld/helloWorld');
|
||||
|
||||
describe('PluginManager', () => {
|
||||
let pluginManager;
|
||||
@ -180,7 +180,7 @@ describe('PluginManager', () => {
|
||||
|
||||
describe('#loadAllPlugins()', () => {
|
||||
it('should load only core plugins when no service plugins are given', () => {
|
||||
// Note: We need the HelloWorld plugin for this test to pass
|
||||
// Note: We need the helloWorld plugin for this test to pass
|
||||
pluginManager.loadAllPlugins();
|
||||
|
||||
expect(pluginManager.plugins).to.include(helloWorld);
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
const expect = require('chai').expect;
|
||||
const exec = require('child_process').exec;
|
||||
const path = require('path');
|
||||
const TestsPlugin = require('../../lib/plugins/Tests/Tests');
|
||||
const TestsPlugin = require('../../lib/plugins/tests/tests');
|
||||
|
||||
describe('Serverless integration tests', () => {
|
||||
it('should successfully run the "serverless test integration" command', (done) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user