From 2bee8c6d81a9d641996f990636726313345a7224 Mon Sep 17 00:00:00 2001 From: tamarushin Date: Mon, 12 Feb 2018 19:20:08 -0800 Subject: [PATCH 1/6] greet.js initial trial --- lab-tama/.eslintignore | 5 ++ lab-tama/.eslintrc.json | 27 ++++++ lab-tama/.gitignore | 145 +++++++++++++++++++++++++++++++ lab-tama/lib/arithmetic.js | 1 + lab-tama/lib/greet.js | 15 ++++ lab-tama/test/arithmatic-test.js | 0 lab-tama/test/greet-test.js | 31 +++++++ 7 files changed, 224 insertions(+) create mode 100644 lab-tama/.eslintignore create mode 100644 lab-tama/.eslintrc.json create mode 100644 lab-tama/.gitignore create mode 100644 lab-tama/lib/arithmetic.js create mode 100644 lab-tama/lib/greet.js create mode 100644 lab-tama/test/arithmatic-test.js create mode 100644 lab-tama/test/greet-test.js diff --git a/lab-tama/.eslintignore b/lab-tama/.eslintignore new file mode 100644 index 0000000..05b1cf3 --- /dev/null +++ b/lab-tama/.eslintignore @@ -0,0 +1,5 @@ +**/node_modules/* +**/vendor/* +**/*.min.js +**/coverage/* +**/build/* diff --git a/lab-tama/.eslintrc.json b/lab-tama/.eslintrc.json new file mode 100644 index 0000000..886827f --- /dev/null +++ b/lab-tama/.eslintrc.json @@ -0,0 +1,27 @@ +{ + "env": { + "browser": true, + "node": true, + "commonjs": true, + "jest": true, + "es6": true + }, + "globals": { + "err": true, + "req": true, + "res": true, + "next": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "no-console": "off", + "indent": [ "error", 2 ], + "quotes": ["error", "single", { "allowTemplateLiterals": true }], + "comma-dangle": ["error", "always-multiline"], + "semi": [ "error", "always" ], + "linebreak-style": ["error", "unix"] + } +} diff --git a/lab-tama/.gitignore b/lab-tama/.gitignore new file mode 100644 index 0000000..4745950 --- /dev/null +++ b/lab-tama/.gitignore @@ -0,0 +1,145 @@ +# 401 JS +db +**.env +temp +build + +# Created by https://www.gitignore.io/api/vim,osx,node,linux,windows +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Vim ### +# swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] +# session +Session.vim +# temporary +.netrwhist +# auto-generated tag files +tags + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.gitignore.io/api/vim,osx,node,linux,windows diff --git a/lab-tama/lib/arithmetic.js b/lab-tama/lib/arithmetic.js new file mode 100644 index 0000000..a726efc --- /dev/null +++ b/lab-tama/lib/arithmetic.js @@ -0,0 +1 @@ +'use strict'; \ No newline at end of file diff --git a/lab-tama/lib/greet.js b/lab-tama/lib/greet.js new file mode 100644 index 0000000..3011959 --- /dev/null +++ b/lab-tama/lib/greet.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = exports = {}; + +exports.sayHey = function(name) { + if(name === typeof 'string') return `hello ${name}`; +// return null; +// if (name !== typeof 'string') return null; +// if (!name) throw new Error('name not provided'); +// return `hey ${name}`; +}; + +exports.sayBye = function() { + return 'see ya later'; +}; \ No newline at end of file diff --git a/lab-tama/test/arithmatic-test.js b/lab-tama/test/arithmatic-test.js new file mode 100644 index 0000000..e69de29 diff --git a/lab-tama/test/greet-test.js b/lab-tama/test/greet-test.js new file mode 100644 index 0000000..f285e13 --- /dev/null +++ b/lab-tama/test/greet-test.js @@ -0,0 +1,31 @@ +'use strict'; + +const greet = require('../lib/greet.js'); +const assert = require('assert'); + +describe('Greet Module', function() { + describe('#sayHey', function() { + it('it should return null if name is not a string', function() { + var result = greet.sayHey(1); + assert.ok(result === null); + }); + it.only('it should return hello world', function() { + var result = greet.sayHey('world'); + console.log('result', result); + assert.ok(result === 'hello world', 'not equal to hello world'); + }); + // it ('should throw a missing name error', function() { + // assert.throws(function() { + // greet.sayHey(); + // }, 'error not thrown'); + // }); + }); + describe('#sayBye', function() { + it('should return see ya later', function() { + var bye = greet.sayBye(); + assert.ok(bye === 'see ya later', 'not equal to see ya later'); + }); + }); +}); + + From a87d11c8831493c180aab80cc10434d97c1ddd90 Mon Sep 17 00:00:00 2001 From: tamarushin Date: Mon, 12 Feb 2018 21:25:55 -0800 Subject: [PATCH 2/6] greet test is working --- lab-tama/lib/greet.js | 16 +++++----------- lab-tama/test/greet-test.js | 34 ++++++++++++++-------------------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/lab-tama/lib/greet.js b/lab-tama/lib/greet.js index 3011959..a819fe7 100644 --- a/lab-tama/lib/greet.js +++ b/lab-tama/lib/greet.js @@ -1,15 +1,9 @@ 'use strict'; -module.exports = exports = {}; +module.exports = function(name) { -exports.sayHey = function(name) { - if(name === typeof 'string') return `hello ${name}`; -// return null; -// if (name !== typeof 'string') return null; -// if (!name) throw new Error('name not provided'); -// return `hey ${name}`; + if (arguments.length !== 1) throw new Error('name not provided'); + if (typeof name !== 'string') return null; + + return `hello ${name}`; }; - -exports.sayBye = function() { - return 'see ya later'; -}; \ No newline at end of file diff --git a/lab-tama/test/greet-test.js b/lab-tama/test/greet-test.js index f285e13..b13d159 100644 --- a/lab-tama/test/greet-test.js +++ b/lab-tama/test/greet-test.js @@ -4,28 +4,22 @@ const greet = require('../lib/greet.js'); const assert = require('assert'); describe('Greet Module', function() { - describe('#sayHey', function() { - it('it should return null if name is not a string', function() { - var result = greet.sayHey(1); - assert.ok(result === null); - }); - it.only('it should return hello world', function() { - var result = greet.sayHey('world'); - console.log('result', result); - assert.ok(result === 'hello world', 'not equal to hello world'); - }); - // it ('should throw a missing name error', function() { - // assert.throws(function() { - // greet.sayHey(); - // }, 'error not thrown'); - // }); + it('it should return null if name is not a string', function() { + var result = greet(1); + assert.ok(result === null, 'not equal to null'); }); - describe('#sayBye', function() { - it('should return see ya later', function() { - var bye = greet.sayBye(); - assert.ok(bye === 'see ya later', 'not equal to see ya later'); - }); + it.only('it should return hello world', function() { + var result = greet('world'); + console.log('result', result); + assert.ok(result === 'hello world', 'not equal to hello world'); + }); + it ('should throw a missing name error', function() { + assert.throws(function() { + greet(); + }, 'error not thrown'); }); }); + + From 3e1c0bbd655b14d450f3d3087d5dcb6699b3a020 Mon Sep 17 00:00:00 2001 From: tamarushin Date: Mon, 12 Feb 2018 22:17:54 -0800 Subject: [PATCH 3/6] arithmatic test not even close yet --- lab-tama/lib/arithmetic.js | 9 ++++++++- lab-tama/test/arithmatic-test.js | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lab-tama/lib/arithmetic.js b/lab-tama/lib/arithmetic.js index a726efc..7f22869 100644 --- a/lab-tama/lib/arithmetic.js +++ b/lab-tama/lib/arithmetic.js @@ -1 +1,8 @@ -'use strict'; \ No newline at end of file +'use strict'; + +module.exports = exports = {}; + +exports.add = function(number){ + if (!number) throw new Error ('not a number'); + return `hey ${number}`; +}; diff --git a/lab-tama/test/arithmatic-test.js b/lab-tama/test/arithmatic-test.js index e69de29..c01254b 100644 --- a/lab-tama/test/arithmatic-test.js +++ b/lab-tama/test/arithmatic-test.js @@ -0,0 +1,24 @@ +'use strict'; + +const arithmatic = require('../lib/arithmatic.js'); +const assert = require('assert'); + +describe('Arithmatic Module'), function() { + describe('#add', function(){ + it('it should return the sum of two numbers'), function() { + var result = arithmatic.add(5,8); + assert.ok(result === 13, 'not equal to 13'); + }; + + it('should throw a non-number error', function(){ + assert.throws(function() { + mathematics.add(); + }, 'error not thrown'); + }); + }); + + + +// The add method should have a 2 parameters(airty of two) +// if either argument is a non - number the function should return null +// else return the sum of the 2 numbers \ No newline at end of file From ba1661dfc5a1420815332bb57f3bad43d7932a16 Mon Sep 17 00:00:00 2001 From: tamarushin Date: Mon, 12 Feb 2018 22:40:48 -0800 Subject: [PATCH 4/6] arithmatic test not working --- lab-tama/lib/arithmetic.js | 7 ++++--- lab-tama/test/arithmatic-test.js | 18 +++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lab-tama/lib/arithmetic.js b/lab-tama/lib/arithmetic.js index 7f22869..a84170e 100644 --- a/lab-tama/lib/arithmetic.js +++ b/lab-tama/lib/arithmetic.js @@ -2,7 +2,8 @@ module.exports = exports = {}; -exports.add = function(number){ - if (!number) throw new Error ('not a number'); - return `hey ${number}`; +exports.add = function(x,y){ + if (arguments.length !== 13) throw new Error ('not a number'); + if (typeof x !== 'number' || typeof y !== 'number') return null; + return `that adds up to ${x+y}`; }; diff --git a/lab-tama/test/arithmatic-test.js b/lab-tama/test/arithmatic-test.js index c01254b..9ae125c 100644 --- a/lab-tama/test/arithmatic-test.js +++ b/lab-tama/test/arithmatic-test.js @@ -3,17 +3,17 @@ const arithmatic = require('../lib/arithmatic.js'); const assert = require('assert'); -describe('Arithmatic Module'), function() { - describe('#add', function(){ - it('it should return the sum of two numbers'), function() { - var result = arithmatic.add(5,8); - assert.ok(result === 13, 'not equal to 13'); - }; +describe('Arithmatic Module', function() { + describe('#add', function(){ + it('it should return the sum of two numbers', function() { + var result = arithmatic.add(5,8); + assert.equal(result === 13, 'not equal to 13'); + }); it('should throw a non-number error', function(){ - assert.throws(function() { - mathematics.add(); - }, 'error not thrown'); + assert.throws(function() { + mathematics.add(); + }, 'error not thrown'); }); }); From bac3e15520302dfb9f4124c93e626ff35c226ae8 Mon Sep 17 00:00:00 2001 From: tamarushin Date: Mon, 12 Feb 2018 23:01:38 -0800 Subject: [PATCH 5/6] added subtraction function to mathematic.js --- lab-tama/lib/arithmetic.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lab-tama/lib/arithmetic.js b/lab-tama/lib/arithmetic.js index a84170e..df8a30f 100644 --- a/lab-tama/lib/arithmetic.js +++ b/lab-tama/lib/arithmetic.js @@ -5,5 +5,11 @@ module.exports = exports = {}; exports.add = function(x,y){ if (arguments.length !== 13) throw new Error ('not a number'); if (typeof x !== 'number' || typeof y !== 'number') return null; - return `that adds up to ${x+y}`; + return `that adds up to ${x + y}`; +}; + +exports.subtract = function (x, y) { + if (arguments.length !== 13) throw new Error('not a number'); + if (typeof x !== 'number' || typeof y !== 'number') return null; + return `the product of that is ${x - y}`; }; From f11a2ae79c93928b5c9c7d8a5c39c87689b1dd3b Mon Sep 17 00:00:00 2001 From: tamarushin Date: Wed, 14 Feb 2018 16:36:28 -0800 Subject: [PATCH 6/6] fixed grammatical errors, added dsStore to git ignore, passed functional testing --- lab-tama/.gitignore | 2 ++ lab-tama/lib/arithmatic.js | 15 +++++++++++++++ lab-tama/lib/arithmetic.js | 15 --------------- lab-tama/test/arithmatic-test.js | 10 +++------- lab-tama/test/greet-test.js | 2 +- 5 files changed, 21 insertions(+), 23 deletions(-) create mode 100644 lab-tama/lib/arithmatic.js delete mode 100644 lab-tama/lib/arithmetic.js diff --git a/lab-tama/.gitignore b/lab-tama/.gitignore index 4745950..c14edf8 100644 --- a/lab-tama/.gitignore +++ b/lab-tama/.gitignore @@ -143,3 +143,5 @@ $RECYCLE.BIN/ *.lnk # End of https://www.gitignore.io/api/vim,osx,node,linux,windows + +.DS_Store diff --git a/lab-tama/lib/arithmatic.js b/lab-tama/lib/arithmatic.js new file mode 100644 index 0000000..cb30978 --- /dev/null +++ b/lab-tama/lib/arithmatic.js @@ -0,0 +1,15 @@ +'use strict'; + +module.exports = exports = {}; + +exports.add = function(x, y) { + if (arguments.length !== 2) throw new Error ('not a number'); + if (typeof x !== 'number' || typeof y !== 'number') return null; + return x + y; +}; + +exports.subtract = function (x, y) { + if (arguments.length !== 2) throw new Error('not a number'); + if (typeof x !== 'number' || typeof y !== 'number') return null; + return x - y; +}; diff --git a/lab-tama/lib/arithmetic.js b/lab-tama/lib/arithmetic.js deleted file mode 100644 index df8a30f..0000000 --- a/lab-tama/lib/arithmetic.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = exports = {}; - -exports.add = function(x,y){ - if (arguments.length !== 13) throw new Error ('not a number'); - if (typeof x !== 'number' || typeof y !== 'number') return null; - return `that adds up to ${x + y}`; -}; - -exports.subtract = function (x, y) { - if (arguments.length !== 13) throw new Error('not a number'); - if (typeof x !== 'number' || typeof y !== 'number') return null; - return `the product of that is ${x - y}`; -}; diff --git a/lab-tama/test/arithmatic-test.js b/lab-tama/test/arithmatic-test.js index 9ae125c..c51c17c 100644 --- a/lab-tama/test/arithmatic-test.js +++ b/lab-tama/test/arithmatic-test.js @@ -7,18 +7,14 @@ describe('Arithmatic Module', function() { describe('#add', function(){ it('it should return the sum of two numbers', function() { var result = arithmatic.add(5,8); - assert.equal(result === 13, 'not equal to 13'); + assert.ok(result === 13, 'not equal to 13'); }); it('should throw a non-number error', function(){ assert.throws(function() { - mathematics.add(); + arithmatic.add(); }, 'error not thrown'); }); }); +}); - - -// The add method should have a 2 parameters(airty of two) -// if either argument is a non - number the function should return null -// else return the sum of the 2 numbers \ No newline at end of file diff --git a/lab-tama/test/greet-test.js b/lab-tama/test/greet-test.js index b13d159..a16368c 100644 --- a/lab-tama/test/greet-test.js +++ b/lab-tama/test/greet-test.js @@ -8,7 +8,7 @@ describe('Greet Module', function() { var result = greet(1); assert.ok(result === null, 'not equal to null'); }); - it.only('it should return hello world', function() { + it ('it should return hello world', function() { var result = greet('world'); console.log('result', result); assert.ok(result === 'hello world', 'not equal to hello world');