diff --git a/lab-khalid/index.js b/lab-khalid/index.js new file mode 100644 index 0000000..6d5d385 --- /dev/null +++ b/lab-khalid/index.js @@ -0,0 +1,5 @@ +'use strict'; + +const greeting = require('../lab-khalid/lib/greet.js'); +console.log('working') +greeting.hello(process.argv[2]) diff --git a/lab-khalid/lib/greet.js b/lab-khalid/lib/greet.js new file mode 100644 index 0000000..c2c0998 --- /dev/null +++ b/lab-khalid/lib/greet.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = exports = {}; + +exports.hello = function(name) { + if(arguments.length === 0) throw new Error('Name not received'); + console.log(name); + return `Hello, ${name}!`; +} diff --git a/lab-khalid/test/greeting-test.js b/lab-khalid/test/greeting-test.js new file mode 100644 index 0000000..bd2b6e7 --- /dev/null +++ b/lab-khalid/test/greeting-test.js @@ -0,0 +1,12 @@ +'use strict'; + +const greeting = require('../lib/greet.js'); +const assert = require('assert'); +describe('Greeting module', function() { + describe('#hello', function(){ + it('should return hello khalid', function() { + const result = greeting.hello('khalid'); + assert.ok(result === 'Hello, khalid!', 'Not equal to Hello khalid!'); + }); + }); +});