-
Notifications
You must be signed in to change notification settings - Fork 4
Anthony Robinson #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
|
|
||
| # Created by https://www.gitignore.io/api/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 | ||
|
|
||
| ### 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,node,linux,windows |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,52 +1,10 @@ | ||
|  01: Node Ecosystem | ||
| === | ||
|
|
||
| ## Submission Instructions | ||
| * Work in a fork of this repository | ||
| * Work in a branch on your fork | ||
| * Write all of your code in a directory named `lab-` + `<your name>` **e.g.** `lab-susan` | ||
| * Open a pull request to this repository | ||
| * Submit on canvas a question and observation, how long you spent, and a link to your pull request | ||
|
|
||
| ## Resources | ||
| * [Jest Getting Started](https://facebook.github.io/jest/docs/en/getting-started.html) | ||
| * [Jest Globals](https://facebook.github.io/jest/docs/en/api.html#content) | ||
| * [Jest Expect](https://facebook.github.io/jest/docs/en/expect.html#content) | ||
|
|
||
| ## Configuration | ||
| Configure the root of your repository with the following files and directories. Thoughfully name and organize any aditional configuration or module files. | ||
| * **README.md** - contains documentation | ||
| * **.gitignore** - contains a [robust](http://gitignore.io) `.gitignore` file | ||
| * **.eslintrc** - contains the course linter configuratoin | ||
| * **.eslintignore** - contains the course linter ignore configuration | ||
| * **lib/** - contains module definitions | ||
| * **__test__/** - contains unit tests | ||
|
|
||
| ## Feature Tasks | ||
| #### Greet Module | ||
| Create a NodeJS module in the lib/ directory named `greet.js` that exports a single function. | ||
| * The `greet` function should have a single parameter (arity of one) that should expect a string as it's input | ||
| * The `greet` function should return the input name, concatenated with "hello ": eg. ("hello susan") | ||
| * The `greet` function should return `null` if the input is not a string | ||
|
|
||
| #### Arithmetic Module | ||
| Create a NodeJS module in the lib/ directory named `arithmetic.js` that exports an object. This module should have `add` and `sub` methods that implament addition and subtraction. | ||
| * The `add` method should have an arity of two (define two paramiters) | ||
| * If either parameter is a non-number the function should return null | ||
| * Else return the sum of the 2 numbers | ||
| * The `sub` method should have an arity of two (define two paramiters) | ||
| * If either parameter is a non-number the function should return null | ||
| * Else return the second paramiter subtracted from the first paramiter | ||
|
|
||
| ## Testing | ||
| #### Greet Module Tests | ||
| * Write a test that expects the greet module to return `null` when you supply non string values | ||
| * Write a test the expects the greet module to return `'hello world'` | ||
| * This should happen when invoked with `'world'` as the first argument | ||
|
|
||
| #### Arithmetic Module Tests | ||
| * Test each method for proper use (invoded with number arguments) | ||
| * Test each method for inproper use (invoded with one or more non-numner arguments) | ||
|
|
||
| ## Documentation | ||
| In your README.md describe the exported values of each module defined in your lib/ directory. Every function description should include it's airty (expected number of paramiters), the expected data for each paramiter (data-type and limitations), and it's behavior (for both valid and invalued use). Feel free to write any additional information in your README.md. | ||
| <h1> Arithmetic Methods </h1> | ||
| In this function we have 2 methods with 2 airtys each, add and sub. | ||
| add takes in two integers, adds them and returns the sum. | ||
| sub takes in two integers, subtracts them and returns the sum. | ||
| if the input value for either method is anything other than an integer it returns null. | ||
|
|
||
| <h1> Greet Method </h1> | ||
| In this function we have 1 method with 1 airty. | ||
| This function takes in a string and concatinates it after hello. | ||
| if anything other than a string is entered the returned value is null. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| 'use strict' | ||
|
|
||
| const arithmetic = require('../lib/arithmetic.js'); | ||
|
|
||
| test('add() should return 2', () => { | ||
| let result = arithmetic.add(1, 1) | ||
| expect(result).toEqual(2) | ||
| }); | ||
|
|
||
| test('add() should return null', () => { | ||
| let result = arithmetic.add() | ||
| expect(result).toEqual(null) | ||
| }); | ||
|
|
||
| test('add() should return 2', () => { | ||
| let result = arithmetic.sub(1, 1) | ||
| expect(result).toEqual(0) | ||
| }); | ||
|
|
||
| test('add() should return null', () => { | ||
| let result = arithmetic.sub() | ||
| expect(result).toEqual(null) | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| 'use strict' | ||
|
|
||
| const greet = require('../lib/greet.js'); | ||
|
|
||
| test('greet() should return "hello Anthony"', () => { | ||
| let result = greet('Anthony') | ||
| expect(result).toEqual('hello Anthony') | ||
| console.log('anthony'); | ||
| }); | ||
|
|
||
| est('greet() should return "hello World"', () => { | ||
| let result = greet('World') | ||
| expect(result).toEqual('hello World') | ||
| console.log('anthony'); | ||
| }); | ||
|
|
||
| test('greet() should return null', () => { | ||
| let result = greet() | ||
| expect(result).toEqual(null) | ||
| console.log('null'); | ||
| }); | ||
|
|
||
| test('greet() should return null', () => { | ||
| let result = greet(123) | ||
| expect(result).toEqual(null) | ||
| console.log('number'); | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo on line 11 . test is missing the t There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove console logs and resubmit for full credit. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| 'use strict' | ||
|
|
||
| module.exports = { | ||
| add: function(a,b){ | ||
| if(typeof a !== 'number' || typeof b !== 'number'){ | ||
| return null; | ||
| } else { | ||
| return a + b; | ||
| } | ||
| }, | ||
| sub: function(a,b){ | ||
| if(typeof a !== 'number' || typeof b !== 'number'){ | ||
| return null; | ||
| } else { | ||
| return a - b; | ||
| } | ||
| } | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use strict' | ||
|
|
||
| module.exports = function(name){ | ||
| if(typeof name === 'string'){ | ||
| return `hello ${name}` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great use of template literal! |
||
| } else { | ||
| return null | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks great, just remember to recheck the test massage when you copy code from a previous test. line 15 says "should return 2".