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
53 changes: 0 additions & 53 deletions README.md

This file was deleted.

5 changes: 5 additions & 0 deletions lab-nicholas/.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-nicholas/.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" ]
}
}
80 changes: 80 additions & 0 deletions lab-nicholas/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

# Created by https://www.gitignore.io/api/node,linux

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


# End of https://www.gitignore.io/api/node,linux
8 changes: 8 additions & 0 deletions lab-nicholas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# arithmetic.js
##arithmetic.sum
arithmetic.sum takes in two numbers, 'a' and 'b' and returns their sum. there is input validation to make sure they are both numbers and 'null' is returned if there is an error.
##arithmetic.sub
arithmetic.sub takes in two numbers, 'a' and 'b' and returns their difference. there is input validation to make sure they are both numbers and 'null' is returned if there is an error.
#greet.js
##greet.greet
greet.greet takes in a string 'name' and returns the concatenated string 'Hello <name>'. There is input validation to make sure 'name' is a string and not empty. It returns 'null if there is an error'
32 changes: 32 additions & 0 deletions lab-nicholas/__test__/arithmetic.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

'use strict';

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

describe('arithmetic.js', () => {
describe('arithmetic.sum', () => {
test('arithmetic.sum should return the sum of the parameters', () => {
expect(arithmetic.sum(2, 4)).toEqual(6);
expect(arithmetic.sum(3, 7)).toEqual(10);
});

test('arithmetic.sum should return null if any input is NaN', () => {
expect(arithmetic.sum('', '')).toEqual(null);
expect(arithmetic.sum(3, 'pineapple')).toEqual(null);
});

});

describe('arithmetic.sub', () => {
test('arithmetic.sub should return the difference of the parameters', () => {
expect(arithmetic.sub(6, 4)).toEqual(2);
expect(arithmetic.sub(17, 7)).toEqual(10);
});

test('arithmetic.sub should return null if any input is NaN', () => {
expect(arithmetic.sub('', '')).toEqual(null);
expect(arithmetic.sub(3, 'pineapple')).toEqual(null);
});

});
});
19 changes: 19 additions & 0 deletions lab-nicholas/__test__/greet.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

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

describe('greet.js', () => {
describe('greet.greet', () => {
test('greet.greet should return hello <name>', () => {
expect(greet.greet('Demi')).toEqual('Hello Demi');
expect(greet.greet('Sam')).toEqual('Hello Sam');
expect(greet.greet('World')).toEqual('Hello World');
});

test('greet.greet should return null if error', () => {
expect(greet.greet('')).toEqual(null);
expect(greet.greet(355641)).toEqual(null);
});

});
});
17 changes: 17 additions & 0 deletions lab-nicholas/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 = (a, b) => {
if(typeof a !== 'number' || typeof b !== 'number'){
return null;
}
return a+b;
};

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

const Greet = module.exports = {};

Greet.greet = (name) => {
if(name === '' || typeof name !== 'string'){
return null;
}
return `Hello ${name}`;
};
14 changes: 14 additions & 0 deletions lab-nicholas/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "lab-nicholas",
"version": "1.0.0",
"description": "jest lab",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
"devDependencies": {
"jest": "^21.2.1"
}
}