diff --git a/lab-nikko/index.js b/lab-nikko/index.js new file mode 100644 index 0000000..9814c45 --- /dev/null +++ b/lab-nikko/index.js @@ -0,0 +1,9 @@ +'use strict'; + +const greet = require('./lib/greet.js'); + +if(process.argv[2]) var name = process.argv[2]; +if(process.argv[2] === undefined) var name = 'Carne Asuhdude'; + +greet.greeting(name); +greet.goodbye(); diff --git a/lab-nikko/lib/greet.js b/lab-nikko/lib/greet.js new file mode 100644 index 0000000..404056b --- /dev/null +++ b/lab-nikko/lib/greet.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = exports = {}; + +exports.greeting = function(name) { + if(arguments.length === 0) throw new Error('No name name given, please input a name!'); + console.log(`Hello ${name}, pleasure to meet you`); + return `Hello ${name}, pleasure to meet you`; +}; + +exports.goodbye = function() { + console.log('thanks for stopping by!'); + return 'thanks for stopping by!'; +}; diff --git a/lab-nikko/test/greet-test.js b/lab-nikko/test/greet-test.js new file mode 100644 index 0000000..d408b91 --- /dev/null +++ b/lab-nikko/test/greet-test.js @@ -0,0 +1,21 @@ +'use strict'; + +const greet = require('../lib/greet.js'); +const assert = require('assert'); + +var name = 'Nikko'; + +describe('Greet Module', function() { + describe('#greeting', function(){ + it(`function should return Hello ${name}, pleasure to meet you`, function(){ + var output = greet.greeting(name); + assert.ok(output === `Hello ${name}, pleasure to meet you`, 'Output does not match - fail'); + }); + }); + describe('#goodbye', function() { + it('function should log: thanks for stopping by!', function() { + var goodbye = greet.goodbye(); + assert.ok(goodbye === 'thanks for stopping by!', 'Output does not match - fail'); + }); + }); +});