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 .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
21 changes: 21 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": [ "error", "single" ],
"semi": ["error", "always"],
"linebreak-style": [ "error", "unix" ]
},
"env": {
"es6": true,
"node": true,
"mocha": true,
"jasmine": true
},
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true,
"impliedStrict": true
},
"extends": "eslint:recommended"
}
136 changes: 136 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Created by https://www.gitignore.io/api/osx,vim,node,macos,windows

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


### OSX ###

# Icon must end with two \r

# Thumbnails

# Files that might appear in the root of a volume

# Directories potentially created on remote AFP share

### 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/osx,vim,node,macos,windows
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@
* 3pts feature tasks
* 3pts tests
* 2pts documentation

## My README.md addition

##### Today we created two files: one that contains a globally scoped function that takes in a string and adds hello to it, and another that contains two functions one that adds two integers and a second that subtracts the first from the second. All functions have exceptions added to them looking for inputs that are not the same type as what the function is expecting, if triggered they will return an error message, if not triggered the functions should continue as expected. Once the functions are set up we wrote tests to test various conditions like making sure the correct data type was entered or making sure the correct phrase or number is returned.
20 changes: 20 additions & 0 deletions lib/arithmetic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

// assigning exports to a empty object and assinging it to the global scope.
module.exports = exports = {};

// adding an add function to the exports variable.
exports.add = function(a, b){
//checking to see if both inputs are numbers, if not stopping the function and throwing an error.
if(typeof(a) !== "number" || typeof(b) !== "number") return 'must be a number/integer'; // NOTE:(just curious if this is the way the function was supposed to fail?) throw new Error('must be a number/integer');
// if it passes it will return the sum.
return a + b;
};

// adding an sub function to the exports variable.
exports.sub = function(a, b){
//checking to see if both inputs are numbers, if not stopping the function and throwing an error.
if(typeof(a) !== "number" || typeof(b) !== "number") return 'must be a number/integer';// NOTE: throw new Error('must be a number/integer');
// if it passes it will return the difference.
return a - b;
};
12 changes: 12 additions & 0 deletions lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

// assigning exports to a empty object and assinging it to the global scope.
module.exports = exports = {};

// creating a hello function and attaching it to the globally scoped exports variable.
exports.hello = function(str){
// checking to see if there is some form of input if not returning null.
if(typeof(str) !== "string") return null;
// returns hello and the str input.
return `hello ${str}`;
};
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "01-node_ecosystem",
"version": "1.0.0",
"description": "first lab",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/loganabsher/01-node_ecosystem.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/loganabsher/01-node_ecosystem/issues"
},
"homepage": "https://github.com/loganabsher/01-node_ecosystem#readme"
}
53 changes: 53 additions & 0 deletions test/arithmetic-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

// inporting the arithmetic file and the assert library.
const arithmetic = require('../lib/arithmetic.js');
const assert = require('assert');

// creating a test named "Arithmetic Module".
describe('Arithmetic Module', function(){

// variables for testing.
let a = 10;
let b = 15;
let c = 'a';
let d = true;

// creating a sub catigory looking at the add function.
describe('#add', function(){

// creating the results and inputs that will be tested by both tests.
let result = arithmetic.add(a, b);

// describing the test.
it('should return Number/Integer', function(){
// checking to see if both values are numbers.
assert.ok(typeof(a) === "number" && typeof(b) === "number", 'must be a number');
});

// describing the test.
it('should return a + b', function(){
// seeing if the results are correct.
assert.ok(result === a + b, 'did not add correctly');
});
});

// creating a sub catigory looking at the sub function.
describe('#sub', function(){

// creating the results and inputs that will be tested by both tests.
let result = arithmetic.sub(a, b);

// describing the test.
it('should return Number/Integer', function(){
// checking to see if both values are numbers.
assert.ok(typeof(a) === "number" && typeof(b) === "number", 'must be a number');
});

// describing the test.
it('should return a - b', function(){
// seeing if the results are correct.
assert.ok(result === a - b, 'did not sub correctly');
});
});
});
32 changes: 32 additions & 0 deletions test/greet-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

// inporting the greet file and the assert library.
const greet = require('../lib/greet.js');
const assert = require('assert');

// creating a test named "Greet Module".
describe('Greet Module', function(){

// variables for testing.
let c = 'world!';
let x = 'this is not world!';
let n = true;

// creating a sub catigory looking at the hello function.
describe('#hello', function(){

// describing the test.
it('should return hello world!', function(){
// calling the hello function and passing in a value.
let result = greet.hello(c);
assert.ok(result === 'hello world!', 'not saying \"hello world!\"');
});

// describing the test.
it('should return null if not string', function(){
// calling the hello function and passing in a value.
let result = greet.hello(n);
assert.ok(result === null, 'not returning null');
});
});
});