Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lab-khalid/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const greeting = require('../lab-khalid/lib/greet.js');
console.log('working')
greeting.hello(process.argv[2])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of process.argv here.

9 changes: 9 additions & 0 deletions lab-khalid/lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = exports = {};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're only putting a single function on module.exports, so you don't need to make it an empty object to attach to.


exports.hello = function(name) {
if(arguments.length === 0) throw new Error('Name not received');
console.log(name);
return `Hello, ${name}!`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String interpolation! Woohoo!

}
12 changes: 12 additions & 0 deletions lab-khalid/test/greeting-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

const greeting = require('../lib/greet.js');
const assert = require('assert');
describe('Greeting module', function() {
describe('#hello', function(){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good use of # before the function name in your test's describe block.

it('should return hello khalid', function() {
const result = greeting.hello('khalid');
assert.ok(result === 'Hello, khalid!', 'Not equal to Hello khalid!');
});
});
});