diff --git a/.eslintrc b/.eslintrc index ed20e71b..5ce15861 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,7 +6,7 @@ }, "extends": "eslint:recommended", "rules": { - "strict": "error", + "strict": "off", "callback-return": "warn", "global-require": "error", "new-cap": "warn", diff --git a/test/errors.spec.js b/test/errors.spec.js index 2b40018f..920db12c 100644 --- a/test/errors.spec.js +++ b/test/errors.spec.js @@ -77,7 +77,7 @@ describe('Error handling', () => { it('should fail gracefully if an error is thrown inside the configuration function', function (done) { this.slow(200); let error; - storage = GridFsStorage({ + storage = new GridFsStorage({ url: settings.mongoUrl, file: () => { throw new Error('Error thrown'); @@ -106,7 +106,7 @@ describe('Error handling', () => { it('should fail gracefully if an error is thrown inside a generator function', function (done) { let error; - storage = GridFsStorage({ + storage = new GridFsStorage({ url: settings.mongoUrl, file: function* () { // eslint-disable-line require-yield throw new Error('File error'); @@ -147,7 +147,7 @@ describe('Error handling', () => { setTimeout(() => reject(error), 200); }); - storage = GridFsStorage({db: promise}); + storage = new GridFsStorage({db: promise}); const upload = multer({storage}); @@ -190,7 +190,7 @@ describe('Error handling', () => { return db.close().then(() => db); }) .then(db => { - storage = GridFsStorage({db}); + storage = new GridFsStorage({db}); const upload = multer({storage}); app.post('/close', upload.array('photos', 2), (err, req, res, next) => { @@ -230,7 +230,7 @@ describe('Error handling', () => { it('should throw an error if the mongodb connection fails', function (done) { const connectionSpy = sinon.spy(); - storage = GridFsStorage({ + storage = new GridFsStorage({ url: settings.mongoUrl, }); @@ -262,7 +262,7 @@ describe('Error handling', () => { throw generatedError; }); - storage = GridFsStorage({ + storage = new GridFsStorage({ url: settings.mongoUrl, }); diff --git a/test/generators.spec.js b/test/generators.spec.js index 8ff9e285..e83ed3dd 100644 --- a/test/generators.spec.js +++ b/test/generators.spec.js @@ -109,7 +109,7 @@ describe('ES6 generators', () => { before((done) => { parameters = []; - storage = GridFsStorage({ + storage = new GridFsStorage({ url: setting.mongoUrl, file: function* (req, file) { let counter = 0; @@ -161,7 +161,7 @@ describe('ES6 generators', () => { describe('promises and generators', () => { let result; before((done) => { - storage = GridFsStorage({ + storage = new GridFsStorage({ url: setting.mongoUrl, file: function* () { let counter = 0; @@ -240,7 +240,7 @@ describe('ES6 generators', () => { describe('finite generators', () => { let error; before((done) => { - storage = GridFsStorage({ + storage = new GridFsStorage({ url: setting.mongoUrl, file: function* () { yield { @@ -291,7 +291,7 @@ describe('ES6 generators', () => { describe('rejected promise', () => { let error; before((done) => { - storage = GridFsStorage({ + storage = new GridFsStorage({ url: setting.mongoUrl, file: function* () { yield Promise.reject('reason'); diff --git a/test/legacy.spec.js b/test/legacy.spec.js index 96f952dc..a766c565 100644 --- a/test/legacy.spec.js +++ b/test/legacy.spec.js @@ -241,7 +241,7 @@ describe('Backwards compatibility', () => { }, }), }); - storage = GridFsStorage({url: setting.mongoUrl}); + storage = new GridFsStorage({url: setting.mongoUrl}); storage._legacy = true; storage.on('streamError', errorSpy); storage.on('file', fileSpy); @@ -280,7 +280,7 @@ describe('Backwards compatibility', () => { before((done) => { emitterStub = sinon.stub().callsFake((evt, cb) => { if (evt === 'end') { - cb(); + return cb(); } }); sinon.stub(mongo, 'GridStore').returns({ @@ -292,7 +292,7 @@ describe('Backwards compatibility', () => { }, }), }); - storage = GridFsStorage({url: setting.mongoUrl}); + storage = new GridFsStorage({url: setting.mongoUrl}); storage._legacy = true; storage.on('streamError', errorSpy); storage.on('file', fileSpy); @@ -342,7 +342,7 @@ describe('Backwards compatibility', () => { } return Promise.resolve(db); }); - storage = GridFsStorage({url: setting.mongoUrl}); + storage = new GridFsStorage({url: setting.mongoUrl}); storage.on('connection', (db, client) => { expect(db).to.be.an.instanceOf(mongo.Db); @@ -364,7 +364,7 @@ describe('Backwards compatibility', () => { } return Promise.resolve(client); }); - storage = GridFsStorage({url: setting.mongoUrl}); + storage = new GridFsStorage({url: setting.mongoUrl}); storage.on('connection', (db, client) => { expect(mongoSpy).to.have.callCount(1); diff --git a/test/storage.spec.js b/test/storage.spec.js index 3fa404a6..eea22c2c 100644 --- a/test/storage.spec.js +++ b/test/storage.spec.js @@ -639,7 +639,7 @@ describe('Storage', () => { }, }); - storage2 = GridFsStorage({ + storage2 = new GridFsStorage({ url: settings.mongoUrl, connectionOpts: { poolSize: 10,