diff --git a/lab-shiv/index.js b/lab-shiv/index.js new file mode 100644 index 0000000..0f42487 --- /dev/null +++ b/lab-shiv/index.js @@ -0,0 +1,7 @@ +'use strict'; + +const greet = require('./lib/greet.js'); + +greet.sayHey('Shivvy'); + +greet.sayBye(); diff --git a/lab-shiv/lib/greet.js b/lab-shiv/lib/greet.js new file mode 100644 index 0000000..27e51d2 --- /dev/null +++ b/lab-shiv/lib/greet.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = exports = {}; + +exports.sayHey = function(name) { + if (arguments[0] === undefined) throw new Error('please insert a name'); + return `hey ${name}!`; +} + +exports.sayBye = function() { + console.log('later gator'); +} diff --git a/lab-shiv/test/testgreet.js b/lab-shiv/test/testgreet.js new file mode 100644 index 0000000..10f4742 --- /dev/null +++ b/lab-shiv/test/testgreet.js @@ -0,0 +1,18 @@ +'use strict'; + +const greet = require('../lib/greet.js'); //don't forget .js and the quotes as well in order to put it into a strin +const assert = require('assert'); //requiring itself + +describe('Greeting Module', function() { + describe ('#greet', function() { + it('should return hey Shivvy!', function() { + var result = greet.sayHey('Shivvy'); + assert.ok(result === 'hey Shivvy!', 'the input and output do not match'); + }); + it ('will throw an error if no input parameter is given', function() { + assert.throws(function() { + greet.sayHey(); + }, 'error not thrown'); + }) + }) +})