Browse Source

Add tests

master
Jake Howard 5 years ago
parent
commit
c6c99a0ca1
  1. 8
      .eslintrc
  2. 9
      .istanbul.yml
  3. 8
      package.json
  4. 13
      scripts/runtests
  5. 5
      scripts/test-helper.js
  6. 1
      test/test.js
  7. 7
      tests/basic.test.js

8
.eslintrc

@ -1,5 +1,11 @@
{
"extends": "./node_modules/eslint-config/.eslintrc",
"parser": "babel-eslint",
"globals": { }
"globals": {
"before": true,
"beforeEach": true,
"describe": true,
"it": true,
"expect": true
}
}

9
.istanbul.yml

@ -0,0 +1,9 @@
instrumentation:
root: .
extensions:
- .js
default-excludes: true
include-all-sources: true
excludes: ['tests/**']
reporting:
print: both

8
package.json

@ -4,9 +4,11 @@
"description": "",
"main": "lib/index.js",
"scripts": {
"build": "browserify ./lib/cli.js -o ./test/out.js",
"test": "browserify ./test/test.js -t ./lib/index.js -o ./test/out.js",
"lint": "eslint 'lib/'"
"build-cli": "browserify ./lib/cli.js -o ./bin/cli.js",
"test": "./scripts/runtests",
"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",
"author": "TheOrangeOne <git@theorangeone.net>",

13
scripts/runtests

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

@ -0,0 +1,5 @@
const chai = require('chai');
const sinonChai = require('sinon-chai');
chai.expect();
chai.use(sinonChai);

1
test/test.js

@ -1 +0,0 @@
console.log('foobar');

7
tests/basic.test.js

@ -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);
});
});
Loading…
Cancel
Save