diff --git a/index.js b/index.js new file mode 100644 index 0000000..a060fc8 --- /dev/null +++ b/index.js @@ -0,0 +1,7 @@ +'use strict'; + +const greet = require('./lib/greet.js'); + +greet.sayHi(); +greet.sayBye(); +greet.randomGreeting(); diff --git a/lib/greet.js b/lib/greet.js new file mode 100644 index 0000000..9dd22df --- /dev/null +++ b/lib/greet.js @@ -0,0 +1,17 @@ +'use strict'; + + +module.exports = exports = {}; + +exports.sayHi = function greet(name) { + if(arguments.length === 0) throw new Error('name not provided'); + return `hello ${name}!`; +}; + +exports.sayBye = function () { + console.log('adios'); + +exports.randomGreeting = function(){ + let someName = process.argv[2]; +} +}; diff --git a/test/greet-test.js b/test/greet-test.js new file mode 100644 index 0000000..241139f --- /dev/null +++ b/test/greet-test.js @@ -0,0 +1,24 @@ +'use strict'; + +const greet = require ('../lib/greet.js'); +const assert = require ('assert'); + +describe('Greeting Module',function() { + describe('#sayHi', function (){ + it('should return hello cayla!', function(){ + var result = greet.sayHi('cayla'); + assert.ok(result === 'hello cayla!', 'not equal to hello cayla'); + }); + it('should throw a missing name name error', function(){ + assert.throws(function(){ + greet.sayHi(); + },'error not thrown'); + }); + }); + describe('#sayBye', function(){ + it('should return see ya later!!', function(){ + var adios = 'see ya later!!'; + assert.ok(adios === 'see ya later!!', 'not equal to see ya later!!'); + }); + }); +});