From cff136abdd9c1c60473f039c03b2ad6286fff329 Mon Sep 17 00:00:00 2001 From: Shiv Unadkat Date: Tue, 14 Feb 2017 09:06:46 -0800 Subject: [PATCH 1/4] greet and index done --- lab-shiv/index.js | 0 lab-shiv/lib/greet.js | 8 ++++++++ lab-shiv/test/testgreet.js | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 lab-shiv/index.js create mode 100644 lab-shiv/lib/greet.js create mode 100644 lab-shiv/test/testgreet.js diff --git a/lab-shiv/index.js b/lab-shiv/index.js new file mode 100644 index 0000000..e69de29 diff --git a/lab-shiv/lib/greet.js b/lab-shiv/lib/greet.js new file mode 100644 index 0000000..58ba2a8 --- /dev/null +++ b/lab-shiv/lib/greet.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = exports = {}; + +module.greet = function (name)= {} { + if (arguments[0] === 0) throw new Eror('please insert a name'); + return `hey ${name}!`; +} diff --git a/lab-shiv/test/testgreet.js b/lab-shiv/test/testgreet.js new file mode 100644 index 0000000..12d6ed2 --- /dev/null +++ b/lab-shiv/test/testgreet.js @@ -0,0 +1,18 @@ +'use strict'; + +const sayHey = require(../lib/greet.js); //don't forget .js +const assert = require('assert'); //requiring itself + +desribe('Greeting Module', function() { + describe ('#greet', function() { + it('should return hey Shivvy!', function() { + var result = sayHey.greet('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'); // + }) + }) // +}) From ee36b25d533d9c50ef94294cf0e2c3bf03e4765b Mon Sep 17 00:00:00 2001 From: Shiv Unadkat Date: Tue, 14 Feb 2017 09:28:06 -0800 Subject: [PATCH 2/4] forget index.js --- lab-shiv/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lab-shiv/index.js b/lab-shiv/index.js index e69de29..19eac00 100644 --- a/lab-shiv/index.js +++ b/lab-shiv/index.js @@ -0,0 +1,3 @@ +'use strict'; + +const seyHey = require('.lib/greet.js'); From f78a93a2c6192146fe6483315bc66e1b9f292b10 Mon Sep 17 00:00:00 2001 From: Shiv Unadkat Date: Sun, 5 Mar 2017 17:07:58 -0800 Subject: [PATCH 3/4] bug fixes and all tests passing --- lab-shiv/index.js | 5 ++++- lab-shiv/lib/greet.js | 8 ++++++-- lab-shiv/test/testgreet.js | 10 +++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lab-shiv/index.js b/lab-shiv/index.js index 19eac00..1694ef9 100644 --- a/lab-shiv/index.js +++ b/lab-shiv/index.js @@ -1,3 +1,6 @@ 'use strict'; -const seyHey = require('.lib/greet.js'); +const sayHey = require('./lib/greet.js'); + +greet.sayHey = ('Shivvy'); +greet.sayBye(); diff --git a/lab-shiv/lib/greet.js b/lab-shiv/lib/greet.js index 58ba2a8..ff08bf5 100644 --- a/lab-shiv/lib/greet.js +++ b/lab-shiv/lib/greet.js @@ -2,7 +2,11 @@ module.exports = exports = {}; -module.greet = function (name)= {} { - if (arguments[0] === 0) throw new Eror('please insert a name'); +exports.sayHey = function(name) { + if (arguments.length[0] === 0) throw new Eror('please insert a name'); return `hey ${name}!`; } + +exports.sayBye = function() { + console.log('later gator'); +} diff --git a/lab-shiv/test/testgreet.js b/lab-shiv/test/testgreet.js index 12d6ed2..01eb017 100644 --- a/lab-shiv/test/testgreet.js +++ b/lab-shiv/test/testgreet.js @@ -1,18 +1,18 @@ 'use strict'; -const sayHey = require(../lib/greet.js); //don't forget .js +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 -desribe('Greeting Module', function() { +describe('Greeting Module', function() { describe ('#greet', function() { it('should return hey Shivvy!', function() { - var result = sayHey.greet('Shivvy'); + 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'); // + }, 'error not thrown'); }) - }) // + }) }) From 2c53d10acaa45835808ca845b26bdafbe2df6292 Mon Sep 17 00:00:00 2001 From: shivprogrammer Date: Fri, 28 Apr 2017 06:24:37 -0700 Subject: [PATCH 4/4] tests passing --- lab-shiv/index.js | 5 +++-- lab-shiv/lib/greet.js | 2 +- lab-shiv/test/testgreet.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lab-shiv/index.js b/lab-shiv/index.js index 1694ef9..0f42487 100644 --- a/lab-shiv/index.js +++ b/lab-shiv/index.js @@ -1,6 +1,7 @@ 'use strict'; -const sayHey = require('./lib/greet.js'); +const greet = require('./lib/greet.js'); + +greet.sayHey('Shivvy'); -greet.sayHey = ('Shivvy'); greet.sayBye(); diff --git a/lab-shiv/lib/greet.js b/lab-shiv/lib/greet.js index ff08bf5..27e51d2 100644 --- a/lab-shiv/lib/greet.js +++ b/lab-shiv/lib/greet.js @@ -3,7 +3,7 @@ module.exports = exports = {}; exports.sayHey = function(name) { - if (arguments.length[0] === 0) throw new Eror('please insert a name'); + if (arguments[0] === undefined) throw new Error('please insert a name'); return `hey ${name}!`; } diff --git a/lab-shiv/test/testgreet.js b/lab-shiv/test/testgreet.js index 01eb017..10f4742 100644 --- a/lab-shiv/test/testgreet.js +++ b/lab-shiv/test/testgreet.js @@ -11,7 +11,7 @@ describe('Greeting Module', function() { }); it ('will throw an error if no input parameter is given', function() { assert.throws(function() { - say.Hey.greet(); + greet.sayHey(); }, 'error not thrown'); }) })