getCandidates is tested in the browser

pull/2/head
Louis Chatriot 12 years ago
parent aaa47a6873
commit 51870a7b60
  1. 35
      browser-version/test/nedb-browser.js

@ -242,4 +242,37 @@ describe('Basic CRUD functionality', function () {
});
});
});
}); // ==== End of 'Basic CRUD functionality' ==== //
describe('Indexing', function () {
it('getCandidates works as expected', function (done) {
var db = new Nedb();
db.insert({ a: 4 }, function () {
db.insert({ a: 6 }, function () {
db.insert({ a: 7 }, function () {
var candidates = db.getCandidates({ a: 6 })
candidates.length.should.equal(3);
assert.isDefined(_.find(candidates, function (doc) { return doc.a === 4; }));
assert.isDefined(_.find(candidates, function (doc) { return doc.a === 6; }));
assert.isDefined(_.find(candidates, function (doc) { return doc.a === 7; }));
db.ensureIndex({ fieldName: 'a' });
candidates = db.getCandidates({ a: 6 })
candidates.length.should.equal(1);
assert.isDefined(_.find(candidates, function (doc) { return doc.a === 6; }));
done();
});
});
});
});
}); // ==== End of 'Indexing' ==== //

Loading…
Cancel
Save