Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish monorepo merge: http-pouchdb #236

Merged
merged 27 commits into from
Jun 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7038454
1.0.0
marten-de-vries Dec 19, 2014
91fb2ab
1.1.0 - adds .isHTTPPouchDB property
marten-de-vries Dec 20, 2014
839360a
(#1) - Make http-pouchdb work with a recent PouchDB
marten-de-vries Jun 30, 2015
a7e1f9d
1.1.2; fixes #2
marten-de-vries Aug 18, 2015
6180f32
Fixes #3 and #4 by including own getHost() impl; some dependency upda…
marten-de-vries Oct 22, 2015
746f863
Container-based Travis
marten-de-vries Oct 22, 2015
59e3ab9
chore(package): update dependencies
greenkeeperio-bot Feb 5, 2016
71a9d62
keep up with pouchdb api
Dec 14, 2016
29aa106
fix destroy
Dec 14, 2016
e5ecf57
Updated dist
marten-de-vries Dec 20, 2016
9620aa4
Updated to 2.0.0
marten-de-vries Dec 20, 2016
edc1dd8
chore(package): update pouchdb to version 6.1.1
greenkeeperio-bot Jan 5, 2017
7d0682f
use bluebird
Jan 16, 2017
b3a9362
node version
Jan 16, 2017
730b498
Merge pull request #22 from pouchdb/greenkeeper-pouchdb-6.1.1
Jan 16, 2017
7468593
chore(package): update mocha to version 3.2.0
greenkeeperio-bot Jan 16, 2017
4e44d4c
Merge pull request #19 from pouchdb/greenkeeper-mocha-3.2.0
Jan 16, 2017
493240e
v2.1.0
Jan 16, 2017
0b28976
Release 2.1.2
Jan 16, 2017
47b159a
chore(package): update browserify to version 14.0.0
greenkeeperio-bot Jan 25, 2017
9b28231
Merge pull request #24 from pouchdb/greenkeeper-browserify-14.0.0
Feb 2, 2017
937568f
Add 'packages/node_modules/http-pouchdb/' from commit '9b28231f2c4079…
gr2m Jun 23, 2017
5173584
http-pouchdb tests
gr2m Jun 23, 2017
a6426c8
http-pouchdb: remove obsolete files
gr2m Jun 26, 2017
15cf6eb
http-pouchdb: remove scripts and dependencies from package.json
gr2m Jun 26, 2017
209701f
http-pouchdb: add `xhr2` dependency to pouchdb-server/package.json
gr2m Jun 26, 2017
5a3d029
http-pouchdb: adapt tests
gr2m Jun 26, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"serve-favicon": "~2.3.2",
"tail": "^1.2.1",
"uuid": "^3.0.1",
"wordwrap": "1.0.0"
"wordwrap": "1.0.0",
"xhr2": "^0.1.3"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
"devDependencies": {
"assert": "^1.4.1",
Expand Down
6 changes: 6 additions & 0 deletions packages/node_modules/http-pouchdb/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions packages/node_modules/http-pouchdb/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions packages/node_modules/http-pouchdb/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions packages/node_modules/http-pouchdb/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions tests/http-pouchdb/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const {PouchDB} = require('pouchdb-plugin-helper/testutils');
const buildHTTPPouchDB = require('../../packages/node_modules/http-pouchdb');
const should = require('chai').should();

var HTTPPouchDB = buildHTTPPouchDB(PouchDB, 'http://localhost:5984/');
var XMLHttpRequest = require('xhr2');
var Promise = require('bluebird');

describe('isHTTPPouchDB', function () {
it('should be set on the HTTPPouchDB object', function () {
HTTPPouchDB.isHTTPPouchDB.should.be.ok;
});
it('should not be set on the PouchDB object', function () {
should.not.exist(PouchDB.isHTTPPouchDB);
});
});

describe('constructor', function () {
it('should create remote databases for normal db names', function () {
var users = new HTTPPouchDB('_users');

return users.info().then(function (info) {
info.should.have.property('db_name');
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the constructor tests are different from the original: https://github.com/pouchdb/http-pouchdb/blob/9b28231f2c40795c045956a6a4b0f3f974c661c9/test/test.js#L25-L39

  • For the unit tests, we start our own pouchdb-server so the data_size does not exist, hence I just check for db_name
    -new HTTPPouchDB('http://localhost:5984/_replicator') is valid with the latest PouchDB, it just encodes all the slashes etc. If that is an error, it’s outside of the scope of http-pouchdb

});
});

describe('destroy', function () {
it("should be possible using the 'class method'", function (done) {
new HTTPPouchDB('test');
HTTPPouchDB.destroy('test', done);
});
it('should be possible using the method', function (done) {
var db = new HTTPPouchDB('test');
db.destroy(done);
});
});

describe('replicate', function () {
it('should work', function () {
HTTPPouchDB.replicate('test-a', 'test-b').on('complete', function (resp) {
resp.status.should.equal('complete');

return dbShouldExist('test-a').then(function () {
return dbShouldExist('test-b');
}).then(function () {
return new PouchDB('http://localhost:5984/test-a').destroy();
}).then(function () {
return new PouchDB('test-b').destroy();
});
});
});
});

function dbShouldExist(name) {
return new Promise(function (resolve) {
var xhr = new XMLHttpRequest();
xhr.onload = function () {
xhr.status.should.equal(200);
resolve();
};
xhr.open('HEAD', 'http://localhost:5984/' + name);
xhr.send();
});
}

describe('allDbs', function () {
it('should return the remote db list', function (done) {
HTTPPouchDB.allDbs(function (err, dbs) {
should.not.exist(err);
dbs.should.contain('_users');
dbs.should.contain('_replicator');

done();
});
});
});