Skip to content

Commit

Permalink
Merge remote branch 'LearnBoost/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoguchi committed Apr 19, 2011
2 parents e846478 + bdd1eab commit 6068d9b
Showing 1 changed file with 4 additions and 35 deletions.
39 changes: 4 additions & 35 deletions test/model.querying.test.js
Expand Up @@ -56,53 +56,43 @@ module.exports = {
'test that find returns a Query': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection);

// query
BlogPostB.find({}).should.be.an.instanceof(Query);
// BlogPostB.find({}).executed.should.be.false;

// query, fields
BlogPostB.find({}, {}).should.be.an.instanceof(Query);
// BlogPostB.find({}, {}).executed.should.be.false;

// query, fields (array)
BlogPostB.find({}, []).should.be.an.instanceof(Query);
// BlogPostB.find({}, []).executed.should.be.false;

// query, fields, options
BlogPostB.find({}, {}, {}).should.be.an.instanceof(Query);
// BlogPostB.find({}, {}, {}).executed.should.be.false;

// query, fields (array), options
BlogPostB.find({}, [], {}).should.be.an.instanceof(Query);
// BlogPostB.find({}, [], {}).executed.should.be.false;

db.close();
},

'test that findOne returns a Query': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection);

// query
BlogPostB.findOne({}).should.be.an.instanceof(Query);
// BlogPostB.findOne({}).executed.should.be.false;

// query, fields
BlogPostB.findOne({}, {}).should.be.an.instanceof(Query);
// BlogPostB.findOne({}, {}).executed.should.be.false;

// query, fields (array)
BlogPostB.findOne({}, []).should.be.an.instanceof(Query);
// BlogPostB.findOne({}, []).executed.should.be.false;

// query, fields, options
BlogPostB.findOne({}, {}, {}).should.be.an.instanceof(Query);
// BlogPostB.findOne({}, {}, {}).executed.should.be.false;

// query, fields (array), options
BlogPostB.findOne({}, [], {}).should.be.an.instanceof(Query);
// BlogPostB.findOne({}, [], {}).executed.should.be.false;

db.close();
},
Expand All @@ -122,72 +112,59 @@ module.exports = {
var db = start()
, BlogPostB = db.model('BlogPostB', collection)
, count = 5
// , count = 10
, q = { _id: new DocumentObjectId }; // make sure the query is fast

function fn () {
--count || db.close();
};

// query
BlogPostB.find(q, fn).should.be.an.instanceof(Query);
// BlogPostB.find(q, fn).executed.should.be.true;

// query, fields
BlogPostB.find(q, {}, fn).should.be.an.instanceof(Query);
// BlogPostB.find(q, {}, fn).executed.should.be.true;

// query, fields (array)
BlogPostB.find(q, [], fn).should.be.an.instanceof(Query);
// BlogPostB.find(q, [], fn).executed.should.be.true;

// query, fields, options
BlogPostB.find(q, {}, {}, fn).should.be.an.instanceof(Query);
// BlogPostB.find(q, {}, {}, fn).executed.should.be.true;

// query, fields (array), options
BlogPostB.find(q, [], {}, fn).should.be.an.instanceof(Query);
// BlogPostB.find(q, [], {}, fn).executed.should.be.true;
},

'test that query is executed where a callback for findOne': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection)
, count = 5
// , count = 10
, q = { _id: new DocumentObjectId }; // make sure the query is fast

function fn () {
--count || db.close();
};

// query
BlogPostB.findOne(q, fn).should.be.an.instanceof(Query);
// BlogPostB.findOne(q, fn).executed.should.be.true;

// query, fields
BlogPostB.findOne(q, {}, fn).should.be.an.instanceof(Query);
// BlogPostB.findOne(q, {}, fn).executed.should.be.true;

// query, fields (array)
BlogPostB.findOne(q, [], fn).should.be.an.instanceof(Query);
// BlogPostB.findOne(q, [], fn).executed.should.be.true;

// query, fields, options
BlogPostB.findOne(q, {}, {}, fn).should.be.an.instanceof(Query);
// BlogPostB.findOne(q, {}, {}, fn).executed.should.be.true;

// query, fields (array), options
BlogPostB.findOne(q, [], {}, fn).should.be.an.instanceof(Query);
// BlogPostB.findOne(q, [], {}, fn).executed.should.be.true;
},

'test that count returns a Query': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection);

BlogPostB.count({}).should.be.an.instanceof(Query);
// BlogPostB.count({}).executed.should.be.false;

db.close();
},
Expand All @@ -196,25 +173,20 @@ module.exports = {
var db = start()
, BlogPostB = db.model('BlogPostB', collection)
, count = 1;
// , count = 2;

function fn () {
--count || db.close();
};

BlogPostB.count({}, fn).should.be.an.instanceof(Query);
// BlogPostB.count({}, fn).executed.should.be.true;
},

'test that update returns a Query': function () {
var db = start()
, BlogPostB = db.model('BlogPostB', collection);

BlogPostB.update({}, {}).should.be.an.instanceof(Query);
// BlogPostB.update({}, {}).executed.should.be.false;

BlogPostB.update({}, {}, {}).should.be.an.instanceof(Query);
// BlogPostB.update({}, {}, {}).executed.should.be.false;

db.close();
},
Expand All @@ -223,17 +195,14 @@ module.exports = {
var db = start()
, BlogPostB = db.model('BlogPostB', collection)
, count = 2;
// , count = 4;

function fn () {
--count || db.close();
};

BlogPostB.update({title: random()}, {}, fn).should.be.an.instanceof(Query);
// BlogPostB.update({title: random()}, {}, fn).executed.should.be.true;

BlogPostB.update({title: random()}, {}, {}, fn).should.be.an.instanceof(Query);
// BlogPostB.update({title: random()}, {}, {}, fn).executed.should.be.true;
},

'test finding a document': function () {
Expand Down

0 comments on commit 6068d9b

Please sign in to comment.