Skip to content

Commit

Permalink
pouchdb#6230 Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dharders committed Nov 21, 2017
1 parent 3e1c274 commit 7ffe3f3
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/integration/test.all_docs.js
Expand Up @@ -751,5 +751,60 @@ adapters.forEach(function (adapter) {
should.not.exist(result.rows[0].doc._conflicts);
});
});

it('#6230 Test allDocs opts update_seq: false', function () {
var db = new PouchDB(dbs.name);
return db.bulkDocs(origDocs).then(function () {
return db.allDocs({
update_seq: false
});
}).then(function (result) {
result.rows.should.have.length(4);
should.not.exist(result.update_seq);
});
});


it('#6230 Test allDocs opts update_seq: true', function () {
var db = new PouchDB(dbs.name);
return db.bulkDocs(origDocs).then(function () {
return db.allDocs({
update_seq: true
});
}).then(function (result) {
result.rows.should.have.length(4);
should.exist(result.update_seq);
result.update_seq.should.satisfy(function (update_seq) {
if (typeof update_seq === 'number' || typeof update_seq === 'string') {
return true;
} else {
return false;
}
});
var normSeq = normalizeSeq(result.update_seq);
normSeq.should.equal(4);
});

function normalizeSeq(seq) {
try {
if (typeof seq === 'string' && seq.indexOf('-') > 0) {
return parseInt(seq.substring(0, seq.indexOf('-')));
}
return seq;
} catch (err) {
return seq;
}
}
});

it('#6230 Test allDocs opts with update_seq missing', function () {
var db = new PouchDB(dbs.name);
return db.bulkDocs(origDocs).then(function () {
return db.allDocs();
}).then(function (result) {
result.rows.should.have.length(4);
should.not.exist(result.update_seq);
});
});
});
});

0 comments on commit 7ffe3f3

Please sign in to comment.