Skip to content

Commit

Permalink
Updated dev dependencies to fix incompatible versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jormaechea committed Jun 19, 2024
1 parent c438846 commit 69d3e38
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
15 changes: 4 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,9 @@ module.exports = {
mocha: true
},

globals: {
__rootpath: true,
coreRequire: true,
mainRequire: true,
JANIS_CORE: true,
JANIS_ENV: true,
JANIS_ENV_ALIAS: true
},

parserOptions: {
sourceType: 'script',
ecmaVersion: 2020
ecmaVersion: 2024
},

rules: {
Expand All @@ -33,6 +24,7 @@ module.exports = {
'consistent-return': 0,
'prefer-template': 0,
'import/no-unresolved': 0,
'import/extensions': 0,
'import/no-extraneous-dependencies': ['error', { devDependencies: ['**/tests/**/*.js', '**/integration-tests/**/*.js'] }],

'no-bitwise': 0,
Expand Down Expand Up @@ -114,6 +106,7 @@ module.exports = {
ObjectExpression: { minProperties: 5, multiline: true, consistent: true },
ObjectPattern: { minProperties: 5, multiline: true, consistent: true }
}],
'nonblock-statement-body-position': ['error', 'below', { overrides: { else: 'any' } }]
'nonblock-statement-body-position': ['error', 'below', { overrides: { else: 'any' } }],
strict: ['error', 'global']
}
};
17 changes: 6 additions & 11 deletions lib/mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ module.exports = class MongoDB {
* @param {GetPagedCallback} callback Function to call for each batch of items
* @returns {Promise<MongoDocument[]>} The list of documents found
*/
async getPaged(model, params = {}, callback) {
async getPaged(model, params, callback) {

params ??= {};

if(!model)
throw new MongoDBError('Invalid or empty model', MongoDBError.codes.INVALID_MODEL);
Expand Down Expand Up @@ -816,16 +818,10 @@ module.exports = class MongoDB {
if(!Array.isArray(indexNames))
throw new MongoDBError('Invalid indexes names: Should exist and must be an array', MongoDBError.codes.INVALID_INDEX);

try {

const results = await Promise.all(indexNames.map(indexName => this.dropIndex(model, indexName)));

// Returns true only when all the results are true otherwise returns false
return results.every(result => !!result);
const results = await Promise.all(indexNames.map(indexName => this.dropIndex(model, indexName)));

} catch(err) {
throw err;
}
// Returns true only when all the results are true otherwise returns false
return results.every(result => !!result);
}

/**
Expand Down Expand Up @@ -913,7 +909,6 @@ module.exports = class MongoDB {
}
}


/**
* @private
*/
Expand Down
2 changes: 0 additions & 2 deletions tests/mongodb-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ describe('MongoWrapper', () => {
const mongoWrapper = new MongoWrapper(config);
await mongoWrapper.makeQuery(model, callback);


sinon.assert.calledOnceWithExactly(RealMongoClient.prototype.connect);

await Events.emit('janiscommerce.ended');
Expand Down Expand Up @@ -206,7 +205,6 @@ describe('MongoWrapper', () => {
sinon.assert.calledOnceWithExactly(closeStub, true);
});


it('Should call the callback, passing the collection defined by the model', async () => {

const collection = {};
Expand Down
7 changes: 4 additions & 3 deletions tests/mongodb.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable max-classes-per-file */

'use strict';

const assert = require('assert');
Expand Down Expand Up @@ -70,7 +72,7 @@ describe('MongoDB', () => {
return collection;
};

const mockChain = (getDbIsSuccessful = true, response = [], collectionExtraData) => {
const mockChain = (getDbIsSuccessful = true, response = [], collectionExtraData = {}) => {

const toArray = response instanceof Error ? sinon.stub().rejects(response) : sinon.stub().resolves(response);
const limit = sinon.stub();
Expand All @@ -89,7 +91,7 @@ describe('MongoDB', () => {
project,
sort,
find,
collection: stubMongo(getDbIsSuccessful, { find, ...(collectionExtraData || {}) })
collection: stubMongo(getDbIsSuccessful, { find, ...collectionExtraData })
};
};

Expand Down Expand Up @@ -1585,7 +1587,6 @@ describe('MongoDB', () => {
}
}), [item, item2], { id }, options));


sinon.assert.notCalled(collection);
sinon.assert.notCalled(updateMany);
});
Expand Down

0 comments on commit 69d3e38

Please sign in to comment.