slouch/test/spec/exclude-design-docs-iterator.js
Geoff Cox 4f8d22e119 fix(test): race conditions (#35)
* test(exclude-design-docs): cannot guarantee order

* fix(test): 10s is not always long enough

* fix(test): 15s is not always long enough
2017-10-06 14:51:39 -07:00

50 lines
1.2 KiB
JavaScript

'use strict';
var Slouch = require('../../scripts'),
utils = require('../utils');
describe('exclude-design-docs-iterator', function () {
var slouch = new Slouch(utils.couchDBURL());
beforeEach(function () {
return utils.createDB();
});
afterEach(function () {
return utils.destroyDB();
});
var createDocs = function () {
return slouch.doc.create(utils.createdDB, {
thing: 'play'
}).then(function () {
return slouch.doc.create(utils.createdDB, {
thing: 'write'
});
}).then(function () {
return slouch.doc.create(utils.createdDB, {
_id: '_design/mydesign',
thing: 'design'
});
});
};
it('should filter', function () {
var docs = {};
return createDocs().then(function () {
return new slouch.ExcludeDesignDocsIterator(slouch.doc.all(utils.createdDB, {
include_docs: true
})).each(function (doc) {
// We cannot guarantee the order when our DB has multiple nodes, but this doesn't matter as
// all we care about is that we didn't receive the design doc.
docs[doc.doc.thing] = true;
});
}).then(function () {
docs.should.eql({
play: true,
write: true
});
});
});
});