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
9 changes: 9 additions & 0 deletions lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = exports = {};

exports.greet = function greet(name) {
return `hello ${name}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

String interpolation! Yay!

}

if(process.argv[2]) console.log(exports.greet(process.argv[2]));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You might consider storing the value of process.argv[2] into a variable for user elsewhere. Saves on typing the complex line of code, and also makes it a bit more human readable.

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

const greet = require('../lib/greet.js');
const assert = require('assert');

describe('Greet Module Test', function(){
describe('#greet', function() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice job using # before the method name when you're testing it.

it('should return hello remi', function() {
var arg = greet.greet('remi');
assert.ok(arg === 'hello remi', 'not equal to hello remi');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good test.

});
});
});