Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updating unit test. 100% code coverage
- Loading branch information
1 parent
6c001b5
commit a36f79c
Showing
13 changed files
with
303 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// adapted from: https://github.com/Khan/style-guides/pull/25 | ||
{ | ||
"plugins": [ | ||
], | ||
"ecmaFeatures": { | ||
"modules": true | ||
}, | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"rules": { | ||
"arrow-parens": [2, "always"], | ||
"arrow-spacing": 2, | ||
"brace-style": 2, | ||
"camelcase": [2, { | ||
"properties": "always" | ||
}], | ||
"comma-dangle": [1, "always-multiline"], | ||
"comma-dangle": [2, "never"], | ||
"comma-spacing": [2, { | ||
"before": false, | ||
"after": true | ||
}], | ||
"eol-last": [0], | ||
"guard-for-in": 2, | ||
//"indent": [2, 4], | ||
"linebreak-style": [2, "unix"], | ||
/* | ||
"max-len": [2, 80, 4, { | ||
"ignoreUrls": true, | ||
"ignorePattern": "^\\s*const\\s.+=\\s*require\\s*\\(" | ||
}], | ||
*/ | ||
"no-alert": 2, | ||
"no-array-constructor": 2, | ||
"no-const-assign": 2, | ||
"no-debugger": 2, | ||
"no-dupe-keys": 2, | ||
"no-new-object": 2, | ||
"no-spaced-func": 2, | ||
"no-this-before-super": 2, | ||
"no-throw-literal": 2, | ||
"no-trailing-spaces": 2, | ||
"no-unreachable": 2, | ||
"no-unused-vars": 1, | ||
"no-var": 0, | ||
//"object-curly-spacing": [2, "always"], | ||
"one-var": [2, "never"], | ||
"prefer-const": 1, | ||
"prefer-template": 2, | ||
"quotes": [2, "single"], | ||
"semi": [2, "always"], | ||
"space-after-keywords": [2, "always"], | ||
"space-before-blocks": 2, | ||
"space-before-function-paren": [2, { | ||
"anonymous": "always", | ||
"named": "never" | ||
}], | ||
"space-infix-ops": 2, | ||
"space-return-throw-case": 2, | ||
"strict": [0, "never"], | ||
"valid-jsdoc": 2 | ||
}, | ||
"extends": "eslint:recommended" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
/node_modules/ | ||
_ignore/ | ||
coverage/ | ||
node_modules/ | ||
.DS_Store | ||
.npm-debug.log | ||
.project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
.git* | ||
_ignore/ | ||
test/ | ||
.DS_Store | ||
.gitignore | ||
.npm-debug.log | ||
.project | ||
.travis.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
var Picker = require('random-picker').Picker; | ||
var picker = new Picker(); // or pass in a seed: var picker = new Picker(seed) | ||
picker.option('male'); | ||
picker.option('female'); | ||
var r1 = picker.pick(); // 50% chance of being 'male' or 'female' | ||
picker.option('male', 22); | ||
picker.option('female', 78); | ||
var r2 = picker.pick(); // now there's a 22% chance of being 'male', and a 78% change of being 'female' | ||
picker.removeAll(); | ||
picker.option('good', 3.42); | ||
picker.option('bad', 3.42); | ||
var r3 = picker.pick(); // now there's a 50% chance of being 'good' or 'bad' | ||
console.log(r1, r2, r3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
language: node_js | ||
node_js: | ||
- "0.10" | ||
before_install: npm install -g grunt-cli | ||
install: npm install | ||
- 'stable' | ||
- '4.2' | ||
- '4.1' | ||
- '4.0' | ||
- '0.12' | ||
- '0.11' | ||
- '0.10' | ||
before_script: | ||
- npm install -g gulp | ||
script: | ||
- gulp test | ||
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls --verbose |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/*eslint no-console: 0 */ | ||
'use strict'; | ||
var gulp = require('gulp'); | ||
var eslint = require('gulp-eslint'); | ||
var isparta = require('isparta'); | ||
var istanbul = require('gulp-istanbul'); | ||
var mocha = require('gulp-mocha'); | ||
var files = { | ||
lint: ['*.js'], | ||
src: ['index.js'], | ||
test: ['test.js'] | ||
}; | ||
|
||
gulp.task('lint', function () { | ||
return gulp.src(files.lint) | ||
// eslint() attaches the lint output to the eslint property | ||
// of the file object so it can be used by other modules. | ||
.pipe(eslint()) | ||
// eslint.format() outputs the lint results to the console. | ||
// Alternatively use eslint.formatEach() (see Docs). | ||
.pipe(eslint.format('stylish')) | ||
// To have the process exit with an error code (1) on | ||
// lint error, return the stream and pipe to failAfterError last. | ||
.pipe(eslint.failAfterError()); | ||
}); | ||
|
||
gulp.task('test', function () { | ||
return gulp.src(files.src) | ||
.pipe(istanbul({ | ||
instrumenter: isparta.Instrumenter, | ||
includeUntested: true | ||
})) | ||
// Force `require` to return covered files | ||
.pipe(istanbul.hookRequire()) | ||
.on('finish', function () { | ||
gulp.src(files.test, {read: false}) | ||
// gulp-mocha needs filepaths so you can't have any plugins before it | ||
.pipe(mocha({ | ||
reporter: 'spec' | ||
})) | ||
.on('error', function (err) { | ||
console.error(err.toString()); | ||
this.emit('end'); | ||
}) | ||
.pipe(istanbul.writeReports({ | ||
dir: './coverage', | ||
reporters: ['lcov', 'json', 'text-summary'] | ||
})); | ||
}); | ||
}); | ||
|
||
gulp.task('watch', function () { | ||
gulp.watch([files.lint], ['lint', 'test']); | ||
}); | ||
|
||
// setup default task | ||
gulp.task('default', ['lint', 'test', 'watch']); | ||
|
||
// handle errors | ||
process.on('uncaughtException', function (e) { | ||
console.error(e); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.