Add tests
This commit is contained in:
parent
501cb12d17
commit
c6c99a0ca1
7 changed files with 46 additions and 5 deletions
|
@ -1,5 +1,11 @@
|
||||||
{
|
{
|
||||||
"extends": "./node_modules/eslint-config/.eslintrc",
|
"extends": "./node_modules/eslint-config/.eslintrc",
|
||||||
"parser": "babel-eslint",
|
"parser": "babel-eslint",
|
||||||
"globals": { }
|
"globals": {
|
||||||
|
"before": true,
|
||||||
|
"beforeEach": true,
|
||||||
|
"describe": true,
|
||||||
|
"it": true,
|
||||||
|
"expect": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
9
.istanbul.yml
Normal file
9
.istanbul.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
instrumentation:
|
||||||
|
root: .
|
||||||
|
extensions:
|
||||||
|
- .js
|
||||||
|
default-excludes: true
|
||||||
|
include-all-sources: true
|
||||||
|
excludes: ['tests/**']
|
||||||
|
reporting:
|
||||||
|
print: both
|
|
@ -4,9 +4,11 @@
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "browserify ./lib/cli.js -o ./test/out.js",
|
"build-cli": "browserify ./lib/cli.js -o ./bin/cli.js",
|
||||||
"test": "browserify ./test/test.js -t ./lib/index.js -o ./test/out.js",
|
"test": "./scripts/runtests",
|
||||||
"lint": "eslint 'lib/'"
|
"lint": "eslint 'lib/'",
|
||||||
|
"coverage": "istanbul cover node_modules/.bin/_mocha -- --require scripts/test-helper.js --bail --recursive 'tests/**/*.js'",
|
||||||
|
"mocha": "mocha --require scripts/test-helper.js --bail 'tests/**/*.js'"
|
||||||
},
|
},
|
||||||
"bin": "./bin/cli.js",
|
"bin": "./bin/cli.js",
|
||||||
"author": "TheOrangeOne <git@theorangeone.net>",
|
"author": "TheOrangeOne <git@theorangeone.net>",
|
||||||
|
|
13
scripts/runtests
Executable file
13
scripts/runtests
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo ">> Linting..."
|
||||||
|
eslint 'lib/'
|
||||||
|
|
||||||
|
|
||||||
|
echo ">> Testing Build..."
|
||||||
|
browserify ./test/test.js -t ./lib/index.js -o ./test/out.js
|
||||||
|
|
||||||
|
echo ">> Testing Project..."
|
||||||
|
npm run coverage
|
5
scripts/test-helper.js
Normal file
5
scripts/test-helper.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
const chai = require('chai');
|
||||||
|
const sinonChai = require('sinon-chai');
|
||||||
|
|
||||||
|
chai.expect();
|
||||||
|
chai.use(sinonChai);
|
|
@ -1 +0,0 @@
|
||||||
console.log('foobar');
|
|
7
tests/basic.test.js
Normal file
7
tests/basic.test.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
const expect = require('chai').expect;
|
||||||
|
|
||||||
|
describe('Basic Mocha Setup', function () {
|
||||||
|
it('adds two and two and gets four', function () {
|
||||||
|
expect(2 + 2).to.equal(4);
|
||||||
|
});
|
||||||
|
});
|
Reference in a new issue