diff --git a/README.md b/README.md index a3aca54..75b6a5b 100644 --- a/README.md +++ b/README.md @@ -56,4 +56,4 @@ * 2pts configuration * 3pts feature tasks * 3pts tests -* 2pts documentation +* 2pts documentation \ No newline at end of file diff --git a/lab-nathan/.eslintignore b/lab-nathan/.eslintignore new file mode 100644 index 0000000..05b1cf3 --- /dev/null +++ b/lab-nathan/.eslintignore @@ -0,0 +1,5 @@ +**/node_modules/* +**/vendor/* +**/*.min.js +**/coverage/* +**/build/* diff --git a/lab-nathan/.eslintrc b/lab-nathan/.eslintrc new file mode 100644 index 0000000..8dc6807 --- /dev/null +++ b/lab-nathan/.eslintrc @@ -0,0 +1,21 @@ +{ + "rules": { + "no-console": "off", + "indent": [ "error", 2 ], + "quotes": [ "error", "single" ], + "semi": ["error", "always"], + "linebreak-style": [ "error", "unix" ] + }, + "env": { + "es6": true, + "node": true, + "mocha": true, + "jasmine": true + }, + "ecmaFeatures": { + "modules": true, + "experimentalObjectRestSpread": true, + "impliedStrict": true + }, + "extends": "eslint:recommended" +} diff --git a/lab-nathan/.gitignore b/lab-nathan/.gitignore new file mode 100644 index 0000000..345130c --- /dev/null +++ b/lab-nathan/.gitignore @@ -0,0 +1,136 @@ +# Created by https://www.gitignore.io/api/osx,vim,node,macos,windows + +### macOS ### +*.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 + +### 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 ### + +# Icon must end with two \r + +# Thumbnails + +# Files that might appear in the root of a volume + +# Directories potentially created on remote AFP share + +### 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/osx,vim,node,macos,windows diff --git a/lab-nathan/README.md b/lab-nathan/README.md new file mode 100644 index 0000000..b1e5d66 --- /dev/null +++ b/lab-nathan/README.md @@ -0,0 +1,7 @@ +# Greet and Arithmetic + +This project contains two node modules, greet and arithmetic. + +The Greet module is a function which accepts a name parameter and returns "hello [name]!". + +The Arithmetic module is an object containing two methods, add and subtract. They both accept two parameters and return the result. \ No newline at end of file diff --git a/lab-nathan/index.js b/lab-nathan/index.js new file mode 100644 index 0000000..e69de29 diff --git a/lab-nathan/lib/arithmetic.js b/lab-nathan/lib/arithmetic.js new file mode 100644 index 0000000..ddc2b0f --- /dev/null +++ b/lab-nathan/lib/arithmetic.js @@ -0,0 +1,20 @@ +'use strict'; + +let arithmetic = {}; +module.exports = arithmetic; + +arithmetic.add = function(a, b) { + if (typeof a !== 'number' || typeof b !== 'number') { + throw new Error('Cannot add non-numbers.'); + } + + return a + b; +}; + +arithmetic.subtract = function(a, b) { + if (typeof a !== 'number' || typeof b !== 'number') { + throw new Error('Cannot subract non-numbers.'); + } + + return a - b; +}; \ No newline at end of file diff --git a/lab-nathan/lib/greet.js b/lab-nathan/lib/greet.js new file mode 100644 index 0000000..fa2e13e --- /dev/null +++ b/lab-nathan/lib/greet.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function(name) { + return typeof name === 'string'? `hello ${name}!` : null; +}; \ No newline at end of file diff --git a/lab-nathan/test/arithmetic-test.js b/lab-nathan/test/arithmetic-test.js new file mode 100644 index 0000000..5dfbdd0 --- /dev/null +++ b/lab-nathan/test/arithmetic-test.js @@ -0,0 +1,33 @@ +'use strict'; + +const arithmetic = require('../lib/arithmetic.js'); +const assert = require('assert'); + +describe('Arithmetic Module', function() { + describe('#add', function() { + it('should return 10', function() { + let result = arithmetic.add(3, 7); + assert.ok(result === 10); + }); + + it('should throw error with non-number inputs.', function() { + assert.throws(function() { + arithmetic.add('a', 4); + }); + }); + }); + + describe('#subtract', function() { + it('should return 10', function() { + let result = arithmetic.subtract(30, 20); + assert.ok(result === 10); + }); + + it('should throw error with non-number inputs.', function() { + assert.throws(function() { + arithmetic.subtract('a', 20); + }); + }); + }); +}); + diff --git a/lab-nathan/test/greet-test.js b/lab-nathan/test/greet-test.js new file mode 100644 index 0000000..e54dd7d --- /dev/null +++ b/lab-nathan/test/greet-test.js @@ -0,0 +1,18 @@ +'use strict'; + +const greet = require('../lib/greet.js'); +const assert = require('assert'); + +describe('Greet Module', function() { + describe('#', function() { + it('should return hello world!', function() { + let result = greet('world'); + assert.ok(result === 'hello world!'); + }); + + it('should return null with a non-string input', function() { + let result = greet(0); + assert.ok(result === null); + }); + }); +}); \ No newline at end of file