Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lab-catherine/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
26 changes: 26 additions & 0 deletions lab-catherine/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"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" ]
}
}
91 changes: 91 additions & 0 deletions lab-catherine/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Created by https://www.gitignore.io/api/osx,node

### 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

# End of https://www.gitignore.io/api/osx,node
6 changes: 6 additions & 0 deletions lab-catherine/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 01: Node Ecosystem

In arithmetic.js I am exporting an object called Arithmetic. The arithmetic.js .sum function has an arity of two (numberOne and numberTwo). These two inputs must be numbers. If they are not numbers then null will be returned. If they are numbers then the sum of their values will be added and returned. The arithmetic.js .sub function has an arity of two (numberOne and numberTwo). These two inputs must also be numbers. If they are not numbers then null will be returned. If they are numbers then the second parameter will be subtracted from the first and the value returned.


In greet.js I am exporting an object called Greet. The greet.js .hello function has an arity of one that accepts a string as input (in our case a name) and returns Hello, <whatever string input is given>. If the input is not a string or is '' then it returns null.
20 changes: 20 additions & 0 deletions lab-catherine/__test__/arithmetic.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const arithmetic = require('../lib/arithmetic');


describe('arithmetic.test.js', () => {
describe('arithmetic.sum', () => {
test('does arithmetic.sum work properly', () => {
expect(arithmetic.sum('nine', 'one')).toBe(null);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would also be a good idea for both add and sub to test for one argument as a number input and the other as non numeric input, one of each.

expect(arithmetic.sum(9, 1)).toBe(10);
});
});

describe('arithmetic.sub', () => {
test('does arithmetic.sub work properly', () => {
expect(arithmetic.sub(9, 1)).toBe(8);
expect(arithmetic.sub('nine', 'one')).toBe(null);
});
});
});
17 changes: 17 additions & 0 deletions lab-catherine/__test__/greet.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const greet = require('../lib/greet');

describe('greet.test.js', () => {
describe('greet.null', () => {
test('testing to return null for non string values', () => {
expect(greet.hello(null)).toBeNull();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should also be inputting an empty string, and returning null, and also testing for a numeric input and returning null

});
});

describe('greet.helloWorld', () => {
test('testing to see that greet module returns hello world', () => {
expect(greet.hello('world')).toBe('Hello, world');
});
});
});
17 changes: 17 additions & 0 deletions lab-catherine/lib/arithmetic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const Arithmetic = module.exports = {};

Arithmetic.sum = (numberOne, numberTwo) => {
if(typeof numberOne !== 'number' || typeof numberTwo !== 'number'){
return null;
}
return numberOne + numberTwo;
};

Arithmetic.sub = (numberOne, numberTwo) => {
if(typeof numberOne !== 'number' || typeof numberTwo !== 'number') {
return null;
}
return numberOne - numberTwo;
};
10 changes: 10 additions & 0 deletions lab-catherine/lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

const Greet = module.exports = {};

Greet.hello = (name) => {
if(name === '' || typeof name !== 'string'){
return null;
}
return `Hello, ${name}`;
};
Loading