-
Notifications
You must be signed in to change notification settings - Fork 156
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
Changes from all commits
7038454
91fb2ab
839360a
a7e1f9d
6180f32
746f863
59e3ab9
71a9d62
29aa106
e5ecf57
9620aa4
edc1dd8
7d0682f
b3a9362
730b498
7468593
4e44d4c
493240e
0b28976
47b159a
9b28231
937568f
5173584
a6426c8
15cf6eb
209701f
5a3d029
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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'); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the
|
||
}); | ||
}); | ||
|
||
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(); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
xhr2
is a new dependency for http-pouchdb: https://github.com/pouchdb/http-pouchdb/blob/9b28231f2c40795c045956a6a4b0f3f974c661c9/package.json#L51