diff --git a/lab-megan/index.js b/lab-megan/index.js new file mode 100644 index 0000000..a2e732d --- /dev/null +++ b/lab-megan/index.js @@ -0,0 +1,10 @@ +'use strict'; + +const greet = require('./lib/greetings.js'); + +process.argv.forEach((val, index) => { + console.log(`${index}: ${val}`); +}); + +greet.sayHello('Scott'); +greet.sayGoodbye(); diff --git a/lab-megan/lib/greetings.js b/lab-megan/lib/greetings.js new file mode 100644 index 0000000..dcf4a2d --- /dev/null +++ b/lab-megan/lib/greetings.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = exports = {}; + +exports.sayHello = function(theName) { + if (arguments.length === 0) throw new Error('No name was given.'); + return(`Hello, ${theName}.`); +}; + +exports.sayGoodbye = function() { + return('Goodbye, it was nice to meet you.'); +}; diff --git a/lab-megan/test/greetings-test.js b/lab-megan/test/greetings-test.js new file mode 100644 index 0000000..8dad6ea --- /dev/null +++ b/lab-megan/test/greetings-test.js @@ -0,0 +1,21 @@ +'use strict'; + +const greet = require('../lib/greetings.js'); + +const assert = require('assert'); + +describe('Greet Module', function () { + describe('#sayHello', function() { + it('should return Hello, Scott.', function () { + var result = greet.sayHello('Scott'); + assert.ok(result === 'Hello, Scott.', 'Not equal to Hello, Scott.'); + }); + }); + + describe('#sayGoodbye', function() { + it('should return Goodbye, it was nice to meet you.', function() { + var goodbye = 'Goodbye, it was nice to meet you.'; + assert.ok(goodbye === 'Goodbye, it was nice to meet you.', 'Not equal to Goodbye, it was nice to meet you.'); + }); + }); +});