mirror of
https://github.com/donl/slouch.git
synced 2026-05-25 22:07:24 -06:00
* test(exclude-design-docs): cannot guarantee order * fix(test): 10s is not always long enough * fix(test): 15s is not always long enough
50 lines
1.2 KiB
JavaScript
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
|
|
});
|
|
});
|
|
});
|
|
});
|