Skip to content

Commit f76c355

Browse files
committed
updated test cases
1 parent b1d2016 commit f76c355

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/operations/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export abstract class CommandCallbackOperation<T = any> extends CommandOperation
163163
super(parent, options);
164164
}
165165

166-
protected executeCommandCallback(
166+
executeCommandCallback(
167167
server: Server,
168168
session: ClientSession | undefined,
169169
cmd: Document,

test/unit/operations/abstract_command.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as sinon from 'sinon';
44
import {
55
type Callback,
66
type ClientSession,
7-
CommandOperation,
7+
CommandCallbackOperation,
88
type CommandOperationOptions,
99
type Document,
1010
type OperationParent,
@@ -13,7 +13,7 @@ import {
1313
} from '../../mongodb';
1414
import { topologyWithPlaceholderClient } from '../../tools/utils';
1515

16-
class ConcreteCommand<T> extends CommandOperation<T> {
16+
class ConcreteCommand<T> extends CommandCallbackOperation<T> {
1717
constructor(parent?: OperationParent, options?: CommandOperationOptions) {
1818
super(parent, options);
1919
}
@@ -49,12 +49,12 @@ describe('class CommandOperation', () => {
4949
});
5050

5151
context('when a server is created', () => {
52-
it('calls server.commandAsync when executeCommand is invoked', async () => {
52+
it('calls executeCommand, which calls server.commandAsync, when executeCommandCallback is invoked', async () => {
5353
const operation = new ConcreteCommand<any>();
5454
const serverSpy = sinon.stub(server, 'commandAsync');
55-
const commandPromise = operation.executeCommand(server, undefined, { ping: 1 });
56-
expect(commandPromise).to.be.instanceOf(Promise);
57-
await commandPromise;
55+
operation.executeCommandCallback(server, undefined, { ping: 1 }, (err, res) => {
56+
err ? err : res;
57+
});
5858
expect(serverSpy).to.have.been.calledOnce;
5959
});
6060
});

0 commit comments

Comments
 (0)