Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions lab-shiv/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

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

greet.sayHey = ('Shivvy');
greet.sayBye();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Where are you defining greet?

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

module.exports = exports = {};

exports.sayHey = function(name) {
if (arguments.length[0] === 0) throw new Eror('please insert a 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.

This line will not work. Look closely at it. See if you can see why.

return `hey ${name}!`;
}

exports.sayBye = function() {
console.log('later gator');
}
18 changes: 18 additions & 0 deletions lab-shiv/test/testgreet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

const greet = require('../lib/greet.js'); //don't forget .js and the quotes as well in order to put it into a strin
const assert = require('assert'); //requiring itself

describe('Greeting Module', function() {
describe ('#greet', function() {
it('should return hey Shivvy!', function() {
var result = greet.sayHey('Shivvy');
assert.ok(result === 'hey Shivvy!', 'the input and output do not match');
});
it ('will throw an error if no input parameter is given', function() {
assert.throws(function() {
say.Hey.greet();
}, 'error not thrown');
})
})
})