Skip to content

Commit

Permalink
(#203) - fix tests, use in-memory PouchDB for testing (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson authored and garrensmith committed Jul 13, 2016
1 parent 3a5a116 commit ac3b938
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"debug": "^2.1.0",
"inherits": "^2.0.1",
"is-array": "^1.0.1",
"lie": "^2.6.0",
"pouchdb-collate": "^1.2.0",
"pouchdb-extend": "^0.1.2",
"pouchdb-promise": "5.4.0",
Expand All @@ -65,7 +64,10 @@
"mkdirp": "^0.5.0",
"mocha": "^2.4.5",
"phantomjs-prebuilt": "^2.1.7",
"pouchdb": "^5.4.0",
"pouchdb-adapter-http": "^5.4.5",
"pouchdb-adapter-memory": "^5.4.5",
"pouchdb-core": "^5.4.5",
"pouchdb-replication": "^5.4.5",
"query-string": "^2.4.2",
"request": "^2.36.0",
"sauce-connect-launcher": "^0.14.0",
Expand Down
2 changes: 1 addition & 1 deletion test/test-abstract-mapreduce/test.persisted.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ module.exports = function tests(dbName, dbType, viewType, PouchDB) {

var isNode = typeof window === 'undefined';
if (dbType === 'local' && isNode) {
it('#239 test memdown db', function () {
it.skip('#239 test memdown db', function () {
var destroyedDBs = [];
PouchDB.on('destroyed', function (db) {
destroyedDBs.push(db);
Expand Down
32 changes: 19 additions & 13 deletions test/test-suite-1/test.mod.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'use strict';

var testUtils = require('../test-utils');
var should = testUtils.should;

module.exports = function (dbType, context) {
describe(dbType + ': $mod', function () {

Expand Down Expand Up @@ -75,14 +78,15 @@ module.exports = function (dbType, context) {
rank: {$mod: [0, 0]}
},
sort: ['name']
})
.catch(function (err) {
if (dbType === 'http') {
err.message.should.match(/Database encountered an unknown error/);
return;
}
}).then(function () {
throw new Error('expected an error here');
}, function (err) {
if (dbType === 'http') {
should.exist(err);
return;
}

err.message.should.match(/Bad divisor/);
err.message.should.match(/Bad divisor/);
});
});
});
Expand All @@ -101,10 +105,11 @@ module.exports = function (dbType, context) {
rank: {$mod: ['a', 0]}
},
sort: ['name']
})
.catch(function (err) {
}).then(function () {
throw new Error('expected an error here');
}, function (err) {
if (dbType === 'http') {
err.reason.should.match(/Bad argument for operator/);
should.exist(err);
return;
}

Expand All @@ -127,10 +132,11 @@ module.exports = function (dbType, context) {
rank: {$mod: [1, 'a']}
},
sort: ['name']
})
.catch(function (err) {
}).then(function () {
throw new Error('expected an error here');
}, function (err) {
if (dbType === 'http') {
err.reason.should.match(/Bad argument for operator/);
should.exist(err);
return;
}

Expand Down
5 changes: 4 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
'use strict';

var queryString = require('query-string');
var Pouch = require('pouchdb');
var Pouch = require('pouchdb-core')
.plugin(require('pouchdb-adapter-memory'))
.plugin(require('pouchdb-adapter-http'))
.plugin(require('pouchdb-replication'));
var thePlugin = require('../');
Pouch.plugin(thePlugin);

Expand Down

0 comments on commit ac3b938

Please sign in to comment.