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

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

greet.sayHi();
greet.sayBye();
greet.randomGreeting();
17 changes: 17 additions & 0 deletions lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';


module.exports = exports = {};

exports.sayHi = function greet(name) {
if(arguments.length === 0) throw new Error('name not provided');
return `hello ${name}!`;
};

exports.sayBye = function () {
console.log('adios');

exports.randomGreeting = function(){
let someName = process.argv[2];
Copy link

Choose a reason for hiding this comment

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

You are grabbing the correct argument here and setting it to a variable. To make this work though you then need to use that variable as a parameter where you call your sayHi function.

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

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

describe('Greeting Module',function() {
describe('#sayHi', function (){
it('should return hello cayla!', function(){
var result = greet.sayHi('cayla');
assert.ok(result === 'hello cayla!', 'not equal to hello cayla');
});
it('should throw a missing name name error', function(){
assert.throws(function(){
greet.sayHi();
},'error not thrown');
});
});
describe('#sayBye', function(){
it('should return see ya later!!', function(){
var adios = 'see ya later!!';
assert.ok(adios === 'see ya later!!', 'not equal to see ya later!!');
});
});
});