diff --git a/lab-alex/.eslintignore b/lab-alex/.eslintignore new file mode 100644 index 0000000..05b1cf3 --- /dev/null +++ b/lab-alex/.eslintignore @@ -0,0 +1,5 @@ +**/node_modules/* +**/vendor/* +**/*.min.js +**/coverage/* +**/build/* diff --git a/lab-alex/.eslintrc.json b/lab-alex/.eslintrc.json new file mode 100644 index 0000000..886827f --- /dev/null +++ b/lab-alex/.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-alex/.gitignore b/lab-alex/.gitignore new file mode 100644 index 0000000..4745950 --- /dev/null +++ b/lab-alex/.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-alex/README.md b/lab-alex/README.md new file mode 100644 index 0000000..0be04b3 --- /dev/null +++ b/lab-alex/README.md @@ -0,0 +1,9 @@ +There are two modules you can use: + +Greet Module: + - *.greet('string') you can add any string as an argument(airty of one) into this method to have it say hello + 'string'. if you do not pass an argument it will throw a null error. + +Arithmatic Module: + - *.add(x,y) you can pass in 2 number arguments(airty of two) and it will add the numbers. if you do not pass in arguments it will throw a null error. + + - *.sub(x,y) you can pass in 2 number arguments(airty of two) and it will subtract y from x. if you do not pass in arguments it will throw a null error. \ No newline at end of file diff --git a/lab-alex/index.js b/lab-alex/index.js new file mode 100644 index 0000000..e69de29 diff --git a/lab-alex/lib/arithmatic.js b/lab-alex/lib/arithmatic.js new file mode 100644 index 0000000..d7c6fb4 --- /dev/null +++ b/lab-alex/lib/arithmatic.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = exports = {}; + +exports.add = function (a, b) { + if (typeof a !== 'number' || typeof b !== 'number') throw new Error('null'); + return a + b; +}; + +exports.sub = function (a, b) { + if (typeof a !== 'number' || typeof b !== 'number') throw new Error('null'); + return a - b; +}; diff --git a/lab-alex/lib/greet.js b/lab-alex/lib/greet.js new file mode 100644 index 0000000..514f0ef --- /dev/null +++ b/lab-alex/lib/greet.js @@ -0,0 +1,8 @@ +'use strict'; + +module.exports = exports = {}; + +exports.greet = function(name) { + if(!name) throw new Error('null'); + return `hello ${name}`; +}; \ No newline at end of file diff --git a/lab-alex/test/greet-test.js b/lab-alex/test/greet-test.js new file mode 100644 index 0000000..695294f --- /dev/null +++ b/lab-alex/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('#greet', function() { + it('it should return hello world', function() { + var result = greet.greet('world'); + assert.ok(result === 'hello world','not equal to world'); + }); + it('should throw a null error', function() { + assert.throws(function() { + greet.greet(); + }, 'error not thrown'); + }); + }); +}); \ No newline at end of file diff --git a/lab-alex/test/math-test.js b/lab-alex/test/math-test.js new file mode 100644 index 0000000..76d7e36 --- /dev/null +++ b/lab-alex/test/math-test.js @@ -0,0 +1,32 @@ +'use strict'; + +const arithmatic = require('../lib/arithmatic.js'); +const assert = require('assert'); + +describe('Arithmatic Module', function() { + describe('#add', function() { + it('it should add the numbers', function() { + var result = arithmatic.add(1,2); + assert.ok(result === 3, 'not correct'); + }); + it('should throw a null error', function() { + assert.throws(function() { + arithmatic.add('x','$'); + + }, 'error not thrown'); + }); + }); + + describe('#sub', function() { + it('should subtract the numbers', function() { + var result = arithmatic.sub(10, 3); + assert.ok(result === 7, 'not correct'); + }); + it('should throw a null error', function() { + assert.throws(function() { + arithmatic.sub('x', '$'); + }, 'error not thrown'); + }); + + }); +}); \ No newline at end of file