From dd20b3b9731d454d3526fd5cf1fa72b0b6420ceb Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Thu, 2 May 2013 14:55:06 +0200 Subject: [PATCH] Can remove multiple documents even after persistence --- test/db.test.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/test/db.test.js b/test/db.test.js index 8a5fa7e..fd72412 100644 --- a/test/db.test.js +++ b/test/db.test.js @@ -360,6 +360,20 @@ describe('Database', function () { var d = new Datastore(testDb) , id1, id2, id3; + // Test DB status + function testPostUpdateState (cb) { + d.find({}, function (err, docs) { + docs.length.should.equal(1); + + Object.keys(docs[0]).length.should.equal(2); + docs[0]._id.should.equal(id1); + docs[0].somedata.should.equal('ok'); + + return cb(); + }); + } + + // Actually launch the test async.waterfall([ function (cb) { d.loadDatabase(function (err) { @@ -379,18 +393,14 @@ describe('Database', function () { d.remove({ somedata: 'again' }, { multi: true }, function (err, n) { assert.isNull(err); n.should.equal(2); - - d.find({}, function (err, docs) { - docs.length.should.equal(1); - - Object.keys(docs[0]).length.should.equal(2); - docs[0]._id.should.equal(id1); - docs[0].somedata.should.equal('ok'); - - return cb(); - }); + return cb(); }); } + , async.apply(testPostUpdateState) + , function (cb) { + d.loadDatabase(function (err) { return cb(err); }); + } + , async.apply(testPostUpdateState) ], done); });