-
Notifications
You must be signed in to change notification settings - Fork 16
finished lab #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
finished lab #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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]) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
module.exports = exports = {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}!`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. String interpolation! Woohoo! |
||
} |
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(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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!'); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
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.