Skip to content

Commit

Permalink
Replaced deprecated MongoDb methods on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
devconcept committed Sep 24, 2018
1 parent e6a0169 commit 9def08b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
26 changes: 15 additions & 11 deletions test/generators.spec.js
Expand Up @@ -20,7 +20,7 @@ describe('ES6 generators', () => {
let result;
before((done) => {

storage = GridFsStorage({
storage = new GridFsStorage({
url: setting.mongoUrl,
file: function* () {
let counter = 0;
Expand Down Expand Up @@ -271,12 +271,14 @@ describe('ES6 generators', () => {
expect(error.storageErrors).to.have.lengthOf(0);
});

it('should not upload any file', function (done) {
it('should not upload any file', () => {
const db = storage.db;
db.collection('fs.files').count({}, (err, count) => {
expect(count).to.equal(0);
done(err);
});
return db
.collection('fs.files')
.estimatedDocumentCount()
.then(count => {
expect(count).to.equal(0);
});
});

it('should throw an error about the ended generator', () => {
Expand Down Expand Up @@ -316,12 +318,14 @@ describe('ES6 generators', () => {
expect(error).to.equal('reason');
});

it('should not upload any file', function (done) {
it('should not upload any file', () => {
const db = storage.db;
db.collection('fs.files').count({}, (err, count) => {
expect(count).to.equal(0);
done(err);
});
return db
.collection('fs.files')
.estimatedDocumentCount()
.then(count => {
expect(count).to.equal(0);
});
});

after(() => cleanStorage(storage));
Expand Down
8 changes: 5 additions & 3 deletions test/utils/testutils.js
Expand Up @@ -17,9 +17,11 @@ function cleanStorage(storage, db, client) {
client = storage.client;
}
if (db) {
return db.dropDatabase().then(() => {
return client ? client.close() : db.close();
});
return db
.dropDatabase()
.then(() => client
? client.close()
: db.close());
} else {
return Promise.resolve();
}
Expand Down

0 comments on commit 9def08b

Please sign in to comment.