Skip to content

Commit

Permalink
Merge pull request #34 from openscript/master
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
openscript authored Feb 17, 2021
2 parents a90d0b1 + 7942395 commit ef811b5
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 116 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ coverage
test/test-bundle.js
npm-debug.log
dist
.nyc_output
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ services:
- couchdb

node_js:
- "5"
- "14"
sudo: false
script: npm run $COMMAND
before_script:
- "npm install add-cors-to-couchdb"
- "./node_modules/.bin/add-cors-to-couchdb"
- curl -X PUT localhost:5984/test

env:
matrix:
Expand Down
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pouchdb-all-dbs",
"version": "1.0.2",
"version": "1.1.0",
"description": "PouchDB allDbs plugin",
"main": "lib/index.js",
"repository": {
Expand All @@ -21,40 +21,40 @@
"url": "https://github.com/nolanlawson/pouchdb-all-dbs/issues"
},
"scripts": {
"test-node": "TEST_DB=testdb istanbul test ./node_modules/mocha/bin/_mocha test/test.js",
"test-node": "TEST_DB=testdb nyc mocha --include test/test.js --exclude test/webrunner.js",
"test-browser": "./bin/test-browser.js",
"jshint": "jshint -c .jshintrc lib/*.js test/test.js",
"test": "npm run jshint && ./bin/run-test.sh",
"build": "mkdir -p dist && browserify . -o dist/pouchdb.all-dbs.js && npm run min",
"min": "uglifyjs dist/pouchdb.all-dbs.js -mc > dist/pouchdb.all-dbs.min.js",
"dev": "browserify test/test.js > test/test-bundle.js && npm run dev-server",
"dev-server": "./bin/dev-server.js",
"coverage": "npm test --coverage && istanbul check-coverage --lines 100 --function 100 --statements 100 --branches 100"
"coverage": "npm test --coverage && nyc check-coverage --lines 100 --function 100 --statements 100 --branches 100"
},
"dependencies": {
"argsarray": "0.0.1",
"es3ify": "^0.1.3",
"es3ify": "^0.2.2",
"inherits": "~2.0.1",
"pouchdb-promise": "5.4.3",
"pouchdb-promise": "6.4.3",
"tiny-queue": "^0.2.0"
},
"devDependencies": {
"bluebird": "^1.0.7",
"browserify": "^12.0.2",
"chai": "^3.5.0",
"chai-as-promised": "^5.3.0",
"http-server": "~0.5.5",
"istanbul": "^0.2.7",
"jshint": "~2.8.0",
"mocha": "^2.4.5",
"bluebird": "^3.7.2",
"browserify": "^17.0.0",
"chai": "^4.3.0",
"chai-as-promised": "^7.1.1",
"http-server": "~0.12.3",
"jshint": "~2.12.0",
"mocha": "^8.3.0",
"nyc": "^15.1.0",
"phantomjs-prebuilt": "^2.1.7",
"pouchdb": "^5.4.0",
"pouchdb": "^7.2.2",
"request": "^2.36.0",
"sauce-connect-launcher": "^0.14.0",
"selenium-standalone": "^5.1.0",
"uglify-js": "^2.4.13",
"watchify": "^3.1.0",
"wd": "^0.2.21"
"sauce-connect-launcher": "^1.3.2",
"selenium-standalone": "^6.23.0",
"uglify-js": "^3.12.7",
"watchify": "^4.0.0",
"wd": "^1.14.0"
},
"browser": {
"crypto": false
Expand Down
145 changes: 51 additions & 94 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,6 @@ dbs.split(',').forEach(function (db) {
});

function tests(dbName) {

// async method takes an array of functions of signature:
// `function (cb) {}`
// each function is called and `callback` is called when all
// functions are done.
// each function calls `cb` to signal completion
// cb is called with error as the first arguments (if any)
// Once all functions are completed (or upon err)
// callback is called `callback(err)`
function async(functions, callback) {
function series(functions) {
callback = callback || function () {
};
if (!functions.length) {
return callback();
}
var fn = functions.shift();
fn.call(fn, function (err) {
if (err) {
callback(err);
return;
}
series(functions);
});
}
series(functions);
}

describe('allDbs', function () {
this.timeout(10000);

Expand Down Expand Up @@ -87,10 +59,8 @@ function tests(dbName) {
});
}
// create db
new PouchDB(pouchName, function (err) {
if (err) {
return after(err);
}
var newPouch = new PouchDB(pouchName);
newPouch.info().then(function() {
PouchDB.allDbs(function (err, dbs) {
if (err) {
return after(err);
Expand Down Expand Up @@ -119,10 +89,9 @@ function tests(dbName) {
});
}
// create db
new PouchDB(pouchName, function (err) {
if (err) {
return after(err);
}

var newPouch = new PouchDB(pouchName);
newPouch.info().then(function() {
PouchDB.allDbs().then(function (dbs) {
// check if pouchName exists in _all_db
dbs.some(function (dbname) {
Expand All @@ -139,10 +108,8 @@ function tests(dbName) {
var pouchName = dbName;
dbs = [dbName];
// create db
new PouchDB(pouchName, function (err) {
if (err) {
return done(err);
}
var newPouch = new PouchDB(pouchName);
newPouch.info().then(function() {
PouchDB.allDbs(function (err, dbs) {
if (err) {
return done(err);
Expand Down Expand Up @@ -176,14 +143,11 @@ function tests(dbName) {
it('Create Multiple Pouches', function (done) {
var pouchNames = [dbName + '_1', dbName + '_2'];
dbs = pouchNames;
async(pouchNames.map(function (pouch) {
return function (callback) {
new PouchDB(pouch, callback);
};
}), function (err) {
if (err) {
return done(err);
}

Promise.all(pouchNames.map(function (pouch) {
var newPouch = new PouchDB(pouch);
return newPouch.info();
})).then(function () {
PouchDB.allDbs(function (err, dbs) {
if (err) {
return done(err);
Expand All @@ -196,27 +160,26 @@ function tests(dbName) {
JSON.stringify(dbs) + ', tested against ' + pouch);
});
// destroy remaining pouches
async(pouchNames.map(function (pouch) {
return function (callback) {
new PouchDB(pouch).destroy(callback);
};
}), function (err) {
Promise.all(pouchNames.map(function (pouch) {
return new PouchDB(pouch).destroy();
})).then(function() {
done();
}).catch(function (err) {
done(err);
});
});
}).catch(function (err) {
done(err);
});
});
it('Create and Destroy Multiple Pouches', function (done) {
var pouchNames = [dbName + '_1', dbName + '_2'];
dbs = pouchNames;
async(pouchNames.map(function (pouch) {
return function (callback) {
new PouchDB(pouch, callback);
};
}), function (err) {
if (err) {
return done(err);
}

Promise.all(pouchNames.map(function (pouch) {
var newPouch = new PouchDB(pouch);
return newPouch.info();
})).then(function () {
PouchDB.allDbs(function (err, dbs) {
if (err) {
return done(err);
Expand All @@ -230,14 +193,9 @@ function tests(dbName) {
//
// Destroy all Pouches
//
async(pouchNames.map(function (pouch) {
return function (callback) {
return new PouchDB(pouch).destroy(callback);
};
}), function (err) {
if (err) {
return done(err);
}
Promise.all(pouchNames.map(function (pouch) {
return new PouchDB(pouch).destroy();
})).then(function() {
PouchDB.allDbs(function (err, dbs) {
if (err) {
return done(err);
Expand All @@ -252,21 +210,20 @@ function tests(dbName) {
});
done();
});
}).catch(function (err) {
done(err);
});
});
}).catch(function (err) {
done(err);
});
});


it('doesn\'t return the mapreduce db', function (done) {

var pouchName = dbName;
dbs = [dbName];
// create db
new PouchDB(pouchName, function (err, db) {
if (err) {
return done(err);
}
var db = new PouchDB(pouchName);
db.info().then(function() {
var ddoc = {
_id: "_design/foo",
views: {
Expand All @@ -290,10 +247,11 @@ function tests(dbName) {
}).then(function (dbs) {
dbs.should.have.length(1);
}).then(function () { done(); }, done);
}).catch(function(err) {
done(err);
});
});


// Test for return value of allDbs
// The format should follow the following rules:
// 1. if an adapter is specified upon Pouch creation, the dbname will
Expand All @@ -305,14 +263,10 @@ function tests(dbName) {
function (done) {
var pouchNames = [dbName + '_1', dbName + '_2'];
dbs = pouchNames;
async(pouchNames.map(function (name) {
return function (callback) {
new PouchDB(name, callback);
};
}), function (err) {
if (err) {
return done(err);
}
Promise.all(pouchNames.map(function (pouch) {
var newPouch = new PouchDB(pouch);
return newPouch.info();
})).then(function () {
// check allDbs output
PouchDB.allDbs(function (err, dbs) {
if (err) {
Expand All @@ -326,11 +280,9 @@ function tests(dbName) {
JSON.stringify(dbs) + ', tested against ' + pouch);
});
// destroy pouches
async(pouchNames.map(function (db) {
return function (callback) {
new PouchDB(db).destroy(callback);
};
}), function (err) {
Promise.all(pouchNames.map(function (pouch) {
return new PouchDB(pouch).destroy();
})).then(function() {
if (err) {
return done(err);
}
Expand All @@ -349,26 +301,31 @@ function tests(dbName) {
});
done();
});
}).catch(function (err) {
done(err);
});
});
}).catch(function (err) {
done(err);
});
});

it('saves databases with names starting with an underscore.', function (done) {
var pouchName = "_" + dbName;
dbs = [pouchName];
// create db
new PouchDB(pouchName, function (err) {
if (err) {
return done(err);
}

var db = new PouchDB(pouchName);
db.info().then(function() {
PouchDB.allDbs(function (err, allDbs) {
if (err) {
return done(err);
}
allDbs.should.deep.equal(dbs);
done();
});
}).catch(function(err) {
done(err);
});
});
});
Expand Down

0 comments on commit ef811b5

Please sign in to comment.