Skip to content

Instantly share code, notes, and snippets.

@daleharvey
Created October 3, 2015 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daleharvey/09d273f5d8502c8aa37a to your computer and use it in GitHub Desktop.
Save daleharvey/09d273f5d8502c8aa37a to your computer and use it in GitHub Desktop.
it('#4276 Triggers paused error', function (done) {
if (!(/http/.test(dbs.remote) && !/http/.test(dbs.name))) {
return done();
}
var err = {
"message": "_writer access is required for this request",
"name": "unauthorized",
"status": 401
};
var ajax = PouchDB.utils.ajax;
PouchDB.utils.ajax = function (opts, cb) {
cb(err);
};
var db = new PouchDB(dbs.name);
var remote = new PouchDB(dbs.remote);
db.bulkDocs([{foo: 'bar'}]).then(function() {
var repl = db.replicate.to(remote, {live: true, retry: true});
repl.on('paused', function(err) {
if (err) {
repl.cancel();
}
});
repl.on('complete', function(res) {
PouchDB.utils.ajax = ajax;
done();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment