5
5
type Callback ,
6
6
type ClientSession ,
7
7
CommandCallbackOperation ,
8
+ CommandOperation ,
8
9
type CommandOperationOptions ,
9
- type Document ,
10
10
type OperationParent ,
11
11
Server ,
12
12
ServerDescription
@@ -18,14 +18,6 @@ class ConcreteCommand<T> extends CommandCallbackOperation<T> {
18
18
super ( parent , options ) ;
19
19
}
20
20
21
- async executeCommand (
22
- server : Server ,
23
- session : ClientSession | undefined ,
24
- cmd : Document
25
- ) : Promise < any > {
26
- return super . executeCommand ( server , session , cmd ) ;
27
- }
28
-
29
21
protected executeCallback (
30
22
server : Server ,
31
23
session : ClientSession | undefined ,
@@ -48,14 +40,18 @@ describe('class CommandOperation', () => {
48
40
) ;
49
41
} ) ;
50
42
51
- context ( 'when a server is created ' , ( ) => {
52
- it ( 'calls executeCommand, which calls server.commandAsync, when executeCommandCallback is invoked' , async ( ) => {
43
+ context ( 'when an operation uses CommandCallbackOperation ' , ( ) => {
44
+ it ( 'calls executeCommand when executeCommandCallback is invoked' , done => {
53
45
const operation = new ConcreteCommand < any > ( ) ;
54
- const serverSpy = sinon . stub ( server , 'commandAsync' ) ;
55
- operation . executeCommandCallback ( server , undefined , { ping : 1 } , ( err , res ) => {
56
- err ? err : res ;
46
+ const operationSpy = sinon . spy ( CommandOperation . prototype , 'executeCommand' ) ;
47
+ operation . executeCommandCallback ( server , undefined , { ping : 1 } , ( ) => {
48
+ try {
49
+ expect ( operationSpy ) . to . have . been . calledOnceWithExactly ( server , undefined , { ping : 1 } ) ;
50
+ done ( ) ;
51
+ } catch ( error ) {
52
+ done ( error ) ;
53
+ }
57
54
} ) ;
58
- expect ( serverSpy ) . to . have . been . calledOnce ;
59
55
} ) ;
60
56
} ) ;
61
57
} ) ;
0 commit comments