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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
11 changes: 11 additions & 0 deletions greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(function() {
exports = module.exports = {};
exports.greet = function(name) {
return 'Hello ' + name;
};

if (!module.parent) {
console.log(exports.greet(process.argv.slice(2)));
};

})();
16 changes: 16 additions & 0 deletions test/greet-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const chai = require('chai');
const expect = chai.expect;
const greeting = require('../greet.js');

describe('Greeting test', () => {
it('should return a greeting with the name passed', () => {
expect(greeting.greet('Stefanie')).to.eql('Hello Stefanie');
})
})

describe('Greeting test via command line utility', () => {
it('should return a greeting with the name passed in the command line', () => {
process.argv = ['node', 'Users/Stefanie/cf/401/class-01/stefanie-hansen/greet.js', 'Stefanie'];
expect(greeting.greet(process.argv.slice(2))).to.eql('Hello Stefanie');
})
})