diff --git a/src/utils.ts b/src/utils.ts index 83351d6f0a..5ad754c932 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -260,12 +260,6 @@ export function decorateWithExplain( maxTimeMS?: number; } { type ExplainCommand = ReturnType; - const isExplainCommand = (doc: Document): doc is ExplainCommand => 'explain' in command; - - if (isExplainCommand(command)) { - return command; - } - const { verbosity, maxTimeMS } = explain; const baseCommand: ExplainCommand = { explain: command, verbosity }; diff --git a/test/unit/utils.test.ts b/test/unit/utils.test.ts index 2975f4b2e2..7494fb080f 100644 --- a/test/unit/utils.test.ts +++ b/test/unit/utils.test.ts @@ -1007,11 +1007,11 @@ describe('driver utils', function () { }); describe('decorateWithExplain()', function () { - it('when the command is a valid explain command, the command is returned unmodified', function () { - const command = Object.freeze({ explain: { hello: 'world' } }); + it('when the command is a valid explain command, the command is still wrapped', function () { + const command = { explain: { hello: 'world' } }; const result = decorateWithExplain(command, Explain.fromOptions({ explain: true })); - expect(result).to.deep.equal(command); + expect(result).to.deep.equal({ explain: command, verbosity: 'allPlansExecution' }); }); it('when the options have a maxTimeMS, it is attached to the explain command', function () {