From f317cacd59548799f6de5b9572bda54337690043 Mon Sep 17 00:00:00 2001 From: Katy Robinson Date: Mon, 12 Feb 2018 15:12:58 -0800 Subject: [PATCH 1/3] basic scaffold --- lab-katy/.eslintignore | 5 ++ lab-katy/.eslintrc.json | 27 ++++++++ lab-katy/.gitignore | 145 ++++++++++++++++++++++++++++++++++++++++ lab-katy/README.md | 0 4 files changed, 177 insertions(+) create mode 100644 lab-katy/.eslintignore create mode 100644 lab-katy/.eslintrc.json create mode 100644 lab-katy/.gitignore create mode 100644 lab-katy/README.md diff --git a/lab-katy/.eslintignore b/lab-katy/.eslintignore new file mode 100644 index 0000000..82ff623 --- /dev/null +++ b/lab-katy/.eslintignore @@ -0,0 +1,5 @@ +**/node_modules/* +**/vendor/* +**/*.min.js +**/coverage/* +**/build/* \ No newline at end of file diff --git a/lab-katy/.eslintrc.json b/lab-katy/.eslintrc.json new file mode 100644 index 0000000..3fe56a5 --- /dev/null +++ b/lab-katy/.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"] + } + } \ No newline at end of file diff --git a/lab-katy/.gitignore b/lab-katy/.gitignore new file mode 100644 index 0000000..4745950 --- /dev/null +++ b/lab-katy/.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-katy/README.md b/lab-katy/README.md new file mode 100644 index 0000000..e69de29 From 2369f971eabdce8cd4c1edb0ad684b8706870d9c Mon Sep 17 00:00:00 2001 From: Katy Robinson Date: Mon, 12 Feb 2018 16:35:27 -0800 Subject: [PATCH 2/3] lab completed --- lab-katy/README.md | 3 +++ lab-katy/__test__/arithmetic-test.js | 19 +++++++++++++++++++ lab-katy/__test__/greet-test.js | 20 ++++++++++++++++++++ lab-katy/lib/arithmetic.js | 14 ++++++++++++++ lab-katy/lib/greet.js | 8 ++++++++ 5 files changed, 64 insertions(+) create mode 100644 lab-katy/__test__/arithmetic-test.js create mode 100644 lab-katy/__test__/greet-test.js create mode 100644 lab-katy/lib/arithmetic.js create mode 100644 lab-katy/lib/greet.js diff --git a/lab-katy/README.md b/lab-katy/README.md index e69de29..fcada08 100644 --- a/lab-katy/README.md +++ b/lab-katy/README.md @@ -0,0 +1,3 @@ +for the addTest and subtractTest modules in my arithmetic file, they accept an airty of two, the expected input is numbers, and the expected output is a sum and a difference respectively, otherwise a result of null if anything other than a number is entered. + +for my sayHello test, it accepts an airty of one, and the expected input is a string. the function should return 'hello' + the string entered, otherwise returning null. \ No newline at end of file diff --git a/lab-katy/__test__/arithmetic-test.js b/lab-katy/__test__/arithmetic-test.js new file mode 100644 index 0000000..7e1336d --- /dev/null +++ b/lab-katy/__test__/arithmetic-test.js @@ -0,0 +1,19 @@ +'use strict'; + +const arithmetic = require('../lib/arithmetic.js'); +const assert = require('assert'); + +describe('Arithmetic Module', function(){ + describe('#addTest', function(){ + it('it should return a sum', function(){ + var result = arithmetic.addTest('1, 2'); + assert.ok(result === '3', 'this aint a number'); + }); + describe('#subtractTest', function(){ + it('it should return second num subtracted from first', function(){ + var result = arithmetic.subtractTest('4, 2'); + assert.ok(result === '2', 'this aint a number'); + }); + }); + }); +}) \ No newline at end of file diff --git a/lab-katy/__test__/greet-test.js b/lab-katy/__test__/greet-test.js new file mode 100644 index 0000000..4097087 --- /dev/null +++ b/lab-katy/__test__/greet-test.js @@ -0,0 +1,20 @@ +'use strict'; + +const greet = require(../lib/greet.js); +const assert = require('assert'); + +describe('Greet Module', function(){ + describe('#sayHello', function(){ + it('it should return hello world', function(){ + //create assertion tests here + var result = greet.sayHello('world'); + assert.ok(result === 'hello world', 'null'); + }); + + // it('should throw a null error for non string values', function(){ + // assert.throws(function(){ + // greet.sayHello(); + // }, 'error not thrown'); + // }); + }); +}) \ No newline at end of file diff --git a/lab-katy/lib/arithmetic.js b/lab-katy/lib/arithmetic.js new file mode 100644 index 0000000..0512817 --- /dev/null +++ b/lab-katy/lib/arithmetic.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = exports = {}; + +exports.addTest = function(a,b){ + if(typeof a != 'number' || typeof b != 'number') throw new Error('null'); + return `sum: ${a + b}`; +}; + +exports.subtractTest = function(a,b){ + if(typeof a != 'number' || typeof b != 'number') throw new Error('null'); + return `difference: ${a - b}`; +}; + diff --git a/lab-katy/lib/greet.js b/lab-katy/lib/greet.js new file mode 100644 index 0000000..5f6eed9 --- /dev/null +++ b/lab-katy/lib/greet.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = exports = {}; + +exports.sayHello = function(world){ + if(typeof world != 'string') throw new Error('this aint a string'); + return `hello ${world}`; +} \ No newline at end of file From a09a0aadbab75a40b7b7706c258382d913059d7f Mon Sep 17 00:00:00 2001 From: Katy Robinson Date: Tue, 13 Feb 2018 17:26:30 -0800 Subject: [PATCH 3/3] resubmit done --- lab-katy/__test__/arithmetic-test.js | 19 ---------------- lab-katy/lib/arithmetic.js | 11 +++++---- lab-katy/test/arithmetic-test.js | 27 +++++++++++++++++++++++ lab-katy/{__test__ => test}/greet-test.js | 2 +- 4 files changed, 35 insertions(+), 24 deletions(-) delete mode 100644 lab-katy/__test__/arithmetic-test.js create mode 100644 lab-katy/test/arithmetic-test.js rename lab-katy/{__test__ => test}/greet-test.js (92%) diff --git a/lab-katy/__test__/arithmetic-test.js b/lab-katy/__test__/arithmetic-test.js deleted file mode 100644 index 7e1336d..0000000 --- a/lab-katy/__test__/arithmetic-test.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -const arithmetic = require('../lib/arithmetic.js'); -const assert = require('assert'); - -describe('Arithmetic Module', function(){ - describe('#addTest', function(){ - it('it should return a sum', function(){ - var result = arithmetic.addTest('1, 2'); - assert.ok(result === '3', 'this aint a number'); - }); - describe('#subtractTest', function(){ - it('it should return second num subtracted from first', function(){ - var result = arithmetic.subtractTest('4, 2'); - assert.ok(result === '2', 'this aint a number'); - }); - }); - }); -}) \ No newline at end of file diff --git a/lab-katy/lib/arithmetic.js b/lab-katy/lib/arithmetic.js index 0512817..ea26279 100644 --- a/lab-katy/lib/arithmetic.js +++ b/lab-katy/lib/arithmetic.js @@ -3,12 +3,15 @@ module.exports = exports = {}; exports.addTest = function(a,b){ - if(typeof a != 'number' || typeof b != 'number') throw new Error('null'); - return `sum: ${a + b}`; + if(typeof a !== 'number' || typeof b !== 'number') return (null); + return a + b; }; exports.subtractTest = function(a,b){ - if(typeof a != 'number' || typeof b != 'number') throw new Error('null'); - return `difference: ${a - b}`; + if(typeof a != 'number' || typeof b != 'number') return (null); + return a - b; }; + + + diff --git a/lab-katy/test/arithmetic-test.js b/lab-katy/test/arithmetic-test.js new file mode 100644 index 0000000..60f6846 --- /dev/null +++ b/lab-katy/test/arithmetic-test.js @@ -0,0 +1,27 @@ +'use strict'; + +const arithmetic = require('../lib/arithmetic.js'); +const assert = require('assert'); + +describe('Arithmetic Module', function(){ + describe('#addTest', function(){ + it('should return a sum', function(){ + var result = arithmetic.addTest(1, 2); + assert.ok(result === 3, 'this aint a number'); + }); + it('should return null', function(){ + var result = arithmetic.addTest('cat'); + assert.ok(result === null) + }); + describe('#subtractTest', function(){ + it('should return second num subtracted from first', function(){ + var result = arithmetic.subtractTest(4, 2); + assert.ok(result === 2, 'this aint a number'); + }); + it('should return null', function(){ + var result = arithmetic.subtractTest('dog'); + assert.ok(result === null); + }); + }); + }); +}) \ No newline at end of file diff --git a/lab-katy/__test__/greet-test.js b/lab-katy/test/greet-test.js similarity index 92% rename from lab-katy/__test__/greet-test.js rename to lab-katy/test/greet-test.js index 4097087..918cf5e 100644 --- a/lab-katy/__test__/greet-test.js +++ b/lab-katy/test/greet-test.js @@ -1,6 +1,6 @@ 'use strict'; -const greet = require(../lib/greet.js); +const greet = require('../lib/greet.js'); const assert = require('assert'); describe('Greet Module', function(){