From 4143a75e3ea212a3effcb55edc92f1daf588fd59 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 9 Oct 2024 13:49:31 -0600 Subject: [PATCH] test --- src/legacy_wrappers/cursors.js | 24 ++++++------------------ test/tools/api.js | 4 ++-- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/legacy_wrappers/cursors.js b/src/legacy_wrappers/cursors.js index 961d50c..8b7a86e 100644 --- a/src/legacy_wrappers/cursors.js +++ b/src/legacy_wrappers/cursors.js @@ -25,15 +25,9 @@ module.exports.makeLegacyFindCursor = function (baseClass) { return maybeCallback(super.count(options), callback); } - explain(verbosity, callback) { - callback = - typeof callback === 'function' - ? callback - : typeof verbosity === 'function' - ? verbosity - : undefined; - verbosity = typeof verbosity !== 'function' ? verbosity : undefined; - return maybeCallback(super.explain(verbosity), callback); + explain(_verbosity, _options, _callback) { + const callback = Array.from(arguments).find(argument => typeof argument === 'function'); + return maybeCallback(super.explain(...arguments), callback); } close(options, callback) { @@ -180,15 +174,9 @@ module.exports.makeLegacyAggregationCursor = function (baseClass) { } class LegacyAggregationCursor extends baseClass { - explain(verbosity, callback) { - callback = - typeof callback === 'function' - ? callback - : typeof verbosity === 'function' - ? verbosity - : undefined; - verbosity = typeof verbosity !== 'function' ? verbosity : undefined; - return maybeCallback(super.explain(verbosity), callback); + explain(_verbosity, _options, _callback) { + const callback = Array.from(arguments).find(argument => typeof argument === 'function'); + return maybeCallback(super.explain(...arguments), callback); } close(options, callback) { diff --git a/test/tools/api.js b/test/tools/api.js index 26ceee5..c7987aa 100644 --- a/test/tools/api.js +++ b/test/tools/api.js @@ -38,7 +38,7 @@ const api = [ { className: 'Admin', method: 'serverStatus', returnType: 'Promise' }, { className: 'Admin', method: 'validateCollection', returnType: 'Promise' }, - { className: 'AggregationCursor', method: 'explain', returnType: 'Promise' }, + { className: 'AggregationCursor', method: 'explain', returnType: 'Promise', possibleCallbackPositions: [1, 2, 3] }, { className: 'AggregationCursor', method: 'clone', returnType: 'AggregationCursor', notAsync: true }, { className: 'FindCursor', method: 'clone', returnType: 'FindCursor', notAsync: true }, @@ -115,7 +115,7 @@ const api = [ { className: 'Db', method: 'watch', returnType: 'ChangeStream', notAsync: true }, { className: 'FindCursor', method: 'count', returnType: 'Promise' }, - { className: 'FindCursor', method: 'explain', returnType: 'Promise' }, + { className: 'FindCursor', method: 'explain', returnType: 'Promise', possibleCallbackPositions: [1,2,3] }, { className: 'GridFSBucket', method: 'delete', returnType: 'Promise', possibleCallbackPositions: [1, 2] }, { className: 'GridFSBucket', method: 'drop', returnType: 'Promise', possibleCallbackPositions: [1, 2] },