This commit is contained in:
Geoff Cox 2017-07-11 22:22:43 -07:00
parent 86ee3b76f8
commit bca9ecb9be
14 changed files with 263 additions and 1 deletions

6
.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
node_modules
.DS_Store
*~
*.log
npm-debug.log
package-lock.json

32
.jshintrc Normal file
View file

@ -0,0 +1,32 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"eqnull": true,
"browser": true,
"node": true,
"strict": true,
"globalstrict": true,
"white": true,
"indent": 2,
"maxlen": 100,
"globals": {
"process": false,
"global": false,
"require": false,
"console": false,
"describe": false,
"before": false,
"beforeEach": false,
"after": false,
"afterEach": false,
"it": false,
"emit": false,
"mocha": false
}
}

6
.npmignore Normal file
View file

@ -0,0 +1,6 @@
.git*
dist
node_modules
.DS_Store
*~
npm-debug.log

View file

@ -1,2 +1,5 @@
# slouch
Interface with CouchDB without the heavy lifting
## Install
$ npm install couch-slouch

55
TESTING.md Normal file
View file

@ -0,0 +1,55 @@
# Testing
## Test in node
This will run the tests in node:
$ npm run node-test
You can also check for 100% code coverage using:
$ npm run node-full-test
You can then view the test coverage by opening cache/coverage/node/lcov-report/index.html in a browser
Run specific tests:
$ npm run node-test -- -- -g 'some reg-ex'
Run specific tests and generate code coverage:
$ npm run node-test -- -- --coverage -g 'some reg-ex'
## Manual browser tests
$ npm run browser-server
Use any browser to visit http://127.0.0.1:8001/index.html
And you can filter the tests, e.g. http://127.0.0.1:8001/index.html?grep=reg-ex
## Automated browser tests
phantomjs:
$ npm run browser-test-phantomjs
You can also filter the tests, e.g.
$ npm run browser-test-phantomjs -- -g 'some reg-ex'
Chrome:
Note: you must have Chrome installed
$ npm run browser-test-phantomjs -- -b selenium:chrome
Firefox:
Note: you must have Firefox installed
$ npm run browser-test-phantomjs -- -b selenium:firefox
Test in phantomjs, generate code coverage and check for 100% coverage:
$ npm run browser-coverage-full-test
You can then view the test coverage by opening cache/coverage/browser/lcov-report/index.html in any browser

6
beautify.json Normal file
View file

@ -0,0 +1,6 @@
{
"indent_size": 2,
"jslint_happy": true,
"wrap_line_length": 100,
"end_with_newline": true
}

2
cache/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

21
circle.yml Normal file
View file

@ -0,0 +1,21 @@
# Doesn't actually work!
# node:
# version: 7.10.0
dependencies:
pre:
- nvm install 7.10.0
- nvm use 7.10.0 && npm install -g npm
override:
- nvm use 7.10.0 && npm install
test:
pre:
- nvm use 7.10.0 && npm run assert-beautified
- nvm use 7.10.0 && npm run jshint
override:
- nvm use 7.10.0 && npm run node-full-test
- nvm use 7.10.0 && npm run browser-test-phantomjs
- nvm use 7.10.0 && npm run browser-coverage-full-test

3
index.js Normal file
View file

@ -0,0 +1,3 @@
'use strict';
module.exports = require('./scripts');

58
package.json Normal file
View file

@ -0,0 +1,58 @@
{
"name": "couch-slouch",
"version": "0.0.1",
"description": "Interface with CouchDB without the heavy lifting",
"main": "index.js",
"repository": {
"type": "git",
"url": "git://github.com/redgeoff/couch-slouch"
},
"keywords": [
"js",
"seed"
],
"author": "Geoffrey Cox",
"license": "MIT",
"bugs": {
"url": "https://github.com/redgeoff/couch-slouch/issues"
},
"scripts": {
"assert-beautified": "beautify-proj -i test -c beautify.json && beautify-proj -i scripts -c beautify.json",
"beautify": "beautify-proj -i test -o . -c beautify.json && beautify-proj -i scripts -o . -c beautify.json",
"jshint": "jshint -c .jshintrc test scripts",
"node-test": "istanbul test --dir cache/coverage/node node_modules/mocha/bin/_mocha test/node.js",
"node-full-test": "npm run node-test --coverage && istanbul check-coverage --lines 100 --function 100 --statements 100 --branches 100",
"browser-server": "node_modules/gofur/scripts/browser/serve.js -c cache -t test/browser.js",
"browser-test": "node_modules/gofur/scripts/browser/test.js -c cache -t test/browser.js",
"browser-test-firefox": "node_modules/gofur/scripts/browser/test.js -c cache -t test/browser.js -b selenium:firefox",
"browser-test-chrome": "node_modules/gofur/scripts/browser/test.js -c cache -t test/browser.js -b selenium:chrome",
"browser-test-phantomjs": "node_modules/gofur/scripts/browser/test.js -c cache -t test/browser.js -b selenium:phantomjs",
"browser-coverage-server": "node_modules/gofur/scripts/browser-coverage/serve.js -c cache -t test/browser.js",
"browser-coverage-test": "node_modules/gofur/scripts/browser-coverage/test.js -c cache -t test/browser.js",
"browser-coverage-report": "istanbul report --dir cache/coverage/browser --root cache/coverage/browser lcov",
"browser-coverage-check": "istanbul check-coverage --lines 100 --function 100 --statements 100 --branches 100 cache/coverage/browser/coverage.json",
"browser-coverage-full-test": "npm run browser-coverage-test && npm run browser-coverage-report && npm run browser-coverage-check",
"test": "npm run assert-beautified && npm run jshint && npm run node-full-test && npm run browser-coverage-full-test",
"TODO-build": "",
"TODO-test-in-sauce": ""
},
"dependencies": {
"bluebird": "^3.5.0"
},
"devDependencies": {
"beautify-proj": "^1.0.0",
"browserify": "^14.4.0",
"chai": "^4.1.0",
"chai-as-promised": "^6.0.0",
"gofur": "^0.0.7",
"istanbul": "^0.4.5",
"jshint": "^2.9.4",
"mocha": "^3.4.2",
"request": "^2.81.0"
},
"greenkeeper": {
"ignore": [
"chai-as-promised"
]
}
}

13
scripts/foo.js Normal file
View file

@ -0,0 +1,13 @@
'use strict';
var Promise = require('bluebird');
var Foo = function () {
this._thing = 'yar';
};
Foo.prototype.bar = function () {
return Promise.resolve(this._thing);
};
module.exports = Foo;

21
test/browser.js Normal file
View file

@ -0,0 +1,21 @@
'use strict';
var chai = require('chai');
chai.use(require('chai-as-promised'));
chai.should();
var Foo = require('../scripts/foo');
require('./node-and-browser');
describe('browser', function () {
it('should test in only the browser', function () {
// TODO: insert tests that can only be tested in the browser
var foo = new Foo();
return foo.bar().then(function (thing) {
thing.should.eql('yar');
});
});
});

15
test/node-and-browser.js Normal file
View file

@ -0,0 +1,15 @@
'use strict';
var Foo = require('../scripts/foo');
describe('node and browser', function () {
it('should test in both node and the browser', function () {
// TODO: insert tests that can be tested in both node and the browser
var foo = new Foo();
return foo.bar().then(function (thing) {
thing.should.eql('yar');
});
});
});

21
test/node.js Normal file
View file

@ -0,0 +1,21 @@
'use strict';
var chai = require('chai');
chai.use(require('chai-as-promised'));
chai.should();
var Foo = require('../scripts/foo');
require('./node-and-browser');
describe('node', function () {
it('should test only in node', function () {
// TODO: insert tests that can only be tested in node
var foo = new Foo();
return foo.bar().then(function (thing) {
thing.should.eql('yar');
});
});
});