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
1 change: 1 addition & 0 deletions lab-andrew/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*/vendor/
26 changes: 26 additions & 0 deletions lab-andrew/.eslintrc.json
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" ]
}
}
92 changes: 92 additions & 0 deletions lab-andrew/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

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

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


# End of https://www.gitignore.io/api/node,macos
11 changes: 11 additions & 0 deletions lab-andrew/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Exported objects

I am exporting an object named Greet out of the greet.js file, and an object named Arithmetic out of the arithmetic.js file.

### Methods

#### Greet
The Greet object has one method which is named hello. It has an arity of 1, it takes an parameter <name> which must be a string, and it will return 'hello <name>'. If <name> is not a string it will return null.

#### Arithmetic
The Arithmetic object has two methods, an add method and a sub method. They both have an arity of 2. Both arguments must be numbers, or else the function will return null. The add method will add the two numbers together, and the sub method will subtract the second argument from the first.
39 changes: 39 additions & 0 deletions lab-andrew/__test__/arithmetic.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict';

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

describe('arithmetic.test.js', () => {

describe('testing arithmetic.add function for non number input', () => {

test('is one invalid input, \'\', and a number returned null', () => {
expect(arithmetic.add('', 3)).toBeNull();
});

});

describe('testing arithmetic.add function for legit input', () => {

test('is good input returned properly', () => {
expect(arithmetic.add(2, 3)).toBe(5);
});

});

describe('testing arithmetic.sub function for non number input', () => {

test('is one invalid input, \'\', and a number returned null', () => {
expect(arithmetic.sub('', 3)).toBeNull();
});

});

describe('testing arithmetic.sub function for legit input', () => {

test('is good input returned properly', () => {
expect(arithmetic.sub(7, 3)).toBe(4);
});

});

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

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

describe('greet.test.js', () => {

describe('testing greet.hello function for non string input', () => {

test('is \'\' returned null', () => {
expect(greet.hello('')).toBeNull();
});

test('is a number returned as null', () => {
expect(greet.hello(9)).toBeNull();
});

});

describe('testing greet.hello function for legit input', () => {

test('is good input returned properly', () => {
expect(greet.hello('world')).toBe('hello world');
});

});

});
13 changes: 13 additions & 0 deletions lab-andrew/lib/arithmetic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

const Arithmetic = module.exports = {};

Arithmetic.add = (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;
};
8 changes: 8 additions & 0 deletions lab-andrew/lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

const Greet = module.exports = {};

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