1
1
import { expect } from 'chai' ;
2
2
import * as sinon from 'sinon' ;
3
- import { promisify } from 'util' ;
4
3
5
4
import {
6
5
Aspect ,
@@ -64,7 +63,7 @@ describe('GetMoreOperation', function () {
64
63
maxTimeMS : 500
65
64
} ;
66
65
67
- await promisify ( operation . executeCallback . bind ( operation ) ) ( server , undefined ) ;
66
+ await operation . execute . bind ( operation ) ( server , undefined ) ;
68
67
expect ( stub . calledOnce ) . to . be . true ;
69
68
const call = stub . getCall ( 0 ) ;
70
69
expect ( call . args [ 0 ] ) . to . equal ( namespace ) ;
@@ -109,7 +108,7 @@ describe('GetMoreOperation', function () {
109
108
it ( 'should build basic getMore command with cursorId and collection' , async ( ) => {
110
109
const getMoreOperation = new GetMoreOperation ( namespace , cursorId , server , { } ) ;
111
110
const stub = sinon . stub ( server , 'command' ) . yieldsRight ( ) ;
112
- await promisify ( getMoreOperation . executeCallback . bind ( getMoreOperation ) ) ( server , undefined ) ;
111
+ await getMoreOperation . execute . bind ( getMoreOperation ) ( server , undefined ) ;
113
112
expect ( stub ) . to . have . been . calledOnceWith ( namespace , {
114
113
getMore : cursorId ,
115
114
collection : namespace . collection
@@ -122,7 +121,7 @@ describe('GetMoreOperation', function () {
122
121
} ;
123
122
const getMoreOperation = new GetMoreOperation ( namespace , cursorId , server , options ) ;
124
123
const stub = sinon . stub ( server , 'command' ) . yieldsRight ( ) ;
125
- await promisify ( getMoreOperation . executeCallback . bind ( getMoreOperation ) ) ( server , undefined ) ;
124
+ await getMoreOperation . execute . bind ( getMoreOperation ) ( server , undefined ) ;
126
125
expect ( stub ) . to . have . been . calledOnceWith (
127
126
namespace ,
128
127
sinon . match . has ( 'batchSize' , options . batchSize )
@@ -135,7 +134,7 @@ describe('GetMoreOperation', function () {
135
134
} ;
136
135
const getMoreOperation = new GetMoreOperation ( namespace , cursorId , server , options ) ;
137
136
const stub = sinon . stub ( server , 'command' ) . yieldsRight ( ) ;
138
- await promisify ( getMoreOperation . executeCallback . bind ( getMoreOperation ) ) ( server , undefined ) ;
137
+ await getMoreOperation . execute . bind ( getMoreOperation ) ( server , undefined ) ;
139
138
expect ( stub ) . to . have . been . calledOnceWith (
140
139
namespace ,
141
140
sinon . match . has ( 'maxTimeMS' , options . maxAwaitTimeMS )
@@ -193,7 +192,7 @@ describe('GetMoreOperation', function () {
193
192
} ;
194
193
const operation = new GetMoreOperation ( namespace , cursorId , server , optionsWithComment ) ;
195
194
const stub = sinon . stub ( server , 'command' ) . yieldsRight ( ) ;
196
- await promisify ( operation . executeCallback . bind ( operation ) ) ( server , undefined ) ;
195
+ await operation . execute . bind ( operation ) ( server , undefined ) ;
197
196
expect ( stub ) . to . have . been . calledOnceWith ( namespace , getMore ) ;
198
197
} ) ;
199
198
}
@@ -216,10 +215,9 @@ describe('GetMoreOperation', function () {
216
215
server ,
217
216
options
218
217
) ;
219
- const error = await promisify ( getMoreOperation . executeCallback . bind ( getMoreOperation ) ) (
220
- server ,
221
- undefined
222
- ) . catch ( error => error ) ;
218
+ const error = await getMoreOperation . execute
219
+ . bind ( getMoreOperation ) ( server , undefined )
220
+ . catch ( error => error ) ;
223
221
expect ( error ) . to . be . instanceOf ( MongoRuntimeError ) ;
224
222
} ) ;
225
223
@@ -230,10 +228,9 @@ describe('GetMoreOperation', function () {
230
228
server ,
231
229
options
232
230
) ;
233
- const error = await promisify ( getMoreOperation . executeCallback . bind ( getMoreOperation ) ) (
234
- server ,
235
- undefined
236
- ) . catch ( error => error ) ;
231
+ const error = await getMoreOperation . execute
232
+ . bind ( getMoreOperation ) ( server , undefined )
233
+ . catch ( error => error ) ;
237
234
expect ( error ) . to . be . instanceOf ( MongoRuntimeError ) ;
238
235
} ) ;
239
236
@@ -244,10 +241,9 @@ describe('GetMoreOperation', function () {
244
241
server ,
245
242
options
246
243
) ;
247
- const error = await promisify ( getMoreOperation . executeCallback . bind ( getMoreOperation ) ) (
248
- server ,
249
- undefined
250
- ) . catch ( error => error ) ;
244
+ const error = await getMoreOperation . execute
245
+ . bind ( getMoreOperation ) ( server , undefined )
246
+ . catch ( error => error ) ;
251
247
expect ( error ) . to . be . instanceOf ( MongoRuntimeError ) ;
252
248
} ) ;
253
249
} ) ;
0 commit comments