diff --git a/lab-regan/index.js b/lab-regan/index.js new file mode 100644 index 0000000..d529a94 --- /dev/null +++ b/lab-regan/index.js @@ -0,0 +1,6 @@ +'use strict'; + +const welcome = require('./lib/greet.js'); + + +welcome.greet('regan'); diff --git a/lab-regan/lib/greet.js b/lab-regan/lib/greet.js new file mode 100644 index 0000000..74c432b --- /dev/null +++ b/lab-regan/lib/greet.js @@ -0,0 +1,24 @@ +'use strict'; + +module.exports = {}; + +//original solution - works! +// module.exports.greet = function(name){ +// return `hello ${name}`; +// }; + +//bonus solution - works! +// module.exports.greet = function(){ +// console.log(`hello ${process.argv[2]}`); +// }; + +//original + bonus solution combined - works! +module.exports.greet = function(name){ + if (process.argv[2]){ + console.log(`hello ${process.argv[2]}`); + return `hello ${process.argv[2]}`; + } else { + console.log(`hello ${name}`); + return `hello ${name}`; + } +}; diff --git a/lab-regan/test/greet-test.js b/lab-regan/test/greet-test.js new file mode 100644 index 0000000..2e2ad2c --- /dev/null +++ b/lab-regan/test/greet-test.js @@ -0,0 +1,14 @@ +'use strict'; + +const welcome = require('../lib/greet.js'); + +const assert = require('assert'); + +describe('Greet Module', function(){ + describe('#sayHello', function(){ + it('Should return "hello regan"', function(){ + var outcome = welcome.greet('regan'); + assert.ok(outcome === 'hello regan', 'not equal to "hello regan"'); + })//end it + })//end describe - '#sayHello' +})//end describe - 'Greet Module'