diff --git a/bin/serverless b/bin/serverless index 0b5a0e911..8a3d357de 100755 --- a/bin/serverless +++ b/bin/serverless @@ -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(); diff --git a/lib/plugins/HelloWorld/tests/HelloWorld.js b/lib/plugins/HelloWorld/tests/HelloWorld.js deleted file mode 100644 index 3d7c69293..000000000 --- a/lib/plugins/HelloWorld/tests/HelloWorld.js +++ /dev/null @@ -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'); - }); - }); -}); diff --git a/lib/plugins/Plugins.json b/lib/plugins/Plugins.json index b804f84c9..55c1f0b4a 100644 --- a/lib/plugins/Plugins.json +++ b/lib/plugins/Plugins.json @@ -2,6 +2,6 @@ "plugins": [ "./deploy/deploy.js", "./create/create.js", - "./HelloWorld/HelloWorld.js" + "./helloWorld/helloWorld.js" ] } diff --git a/lib/plugins/HelloWorld/README.md b/lib/plugins/helloWorld/README.md similarity index 100% rename from lib/plugins/HelloWorld/README.md rename to lib/plugins/helloWorld/README.md diff --git a/lib/plugins/HelloWorld/HelloWorld.js b/lib/plugins/helloWorld/helloWorld.js similarity index 100% rename from lib/plugins/HelloWorld/HelloWorld.js rename to lib/plugins/helloWorld/helloWorld.js diff --git a/lib/plugins/HelloWorld/package.json b/lib/plugins/helloWorld/package.json similarity index 100% rename from lib/plugins/HelloWorld/package.json rename to lib/plugins/helloWorld/package.json diff --git a/lib/plugins/helloWorld/tests/helloWorld.js b/lib/plugins/helloWorld/tests/helloWorld.js new file mode 100644 index 000000000..e3a32a1d8 --- /dev/null +++ b/lib/plugins/helloWorld/tests/helloWorld.js @@ -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'); + }); + }); + }); + }); +}); diff --git a/lib/plugins/Tests/README.md b/lib/plugins/tests/README.md similarity index 100% rename from lib/plugins/Tests/README.md rename to lib/plugins/tests/README.md diff --git a/lib/plugins/Tests/package.json b/lib/plugins/tests/package.json similarity index 100% rename from lib/plugins/Tests/package.json rename to lib/plugins/tests/package.json diff --git a/lib/plugins/Tests/Tests.js b/lib/plugins/tests/tests.js similarity index 100% rename from lib/plugins/Tests/Tests.js rename to lib/plugins/tests/tests.js diff --git a/lib/plugins/Tests/tests/Tests.js b/lib/plugins/tests/tests/tests.js similarity index 90% rename from lib/plugins/Tests/tests/Tests.js rename to lib/plugins/tests/tests/tests.js index b03be166b..9c4892d3b 100644 --- a/lib/plugins/Tests/tests/Tests.js +++ b/lib/plugins/tests/tests/tests.js @@ -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(() => { diff --git a/tests/classes/PluginManager.js b/tests/classes/PluginManager.js index 3964c32a3..a57a04c9b 100644 --- a/tests/classes/PluginManager.js +++ b/tests/classes/PluginManager.js @@ -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); diff --git a/tests/integration/Serverless.js b/tests/integration/Serverless.js index f070108f7..e0fc37499 100644 --- a/tests/integration/Serverless.js +++ b/tests/integration/Serverless.js @@ -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) => {