From d446bdbf36822cb611b432365475080c75b6f3c8 Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Tue, 19 Jan 2016 00:19:48 -0800 Subject: [PATCH] All tests pass --- test/db.test.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/test/db.test.js b/test/db.test.js index 837827d..d467d20 100755 --- a/test/db.test.js +++ b/test/db.test.js @@ -424,7 +424,7 @@ describe('Database', function () { }); // ==== End of 'Insert' ==== // - describe.only('#getCandidates', function () { + describe('#getCandidates', function () { it('Can use an index to get docs with a basic match', function (done) { d.ensureIndex({ fieldName: 'tf' }, function (err) { @@ -539,12 +539,23 @@ describe('Database', function () { assert.isNull(err); assert.isNull(doc); - d.findOne({}, function (err, doc) { - assert.isNull(err); - assert.isNull(doc); + d.on('compaction.done', function () { + // After compaction, no more mention of the document, correctly removed + var datafileContents = fs.readFileSync(testDb, 'utf8'); + datafileContents.split('\n').length.should.equal(2); + assert.isNull(datafileContents.match(/world/)); - done(); + // New datastore on same datafile is empty + var d2 = new Datastore({ filename: testDb, autoload: true }); + d2.findOne({}, function (err, doc) { + assert.isNull(err); + assert.isNull(doc); + + done(); + }); }); + + d.persistence.compactDatafile(); }); }, 101); });