@@ -192,6 +192,54 @@ describe('GetMoreOperation', function () {
192192 }
193193 } ) ;
194194 } ) ;
195+
196+ context ( 'error cases' , ( ) => {
197+ const server = new Server ( new Topology ( [ ] , { } as any ) , new ServerDescription ( '' ) , { } as any ) ;
198+ sinon . stub ( server , 'command' ) . yieldsRight ( ) ;
199+
200+ it ( 'should throw if the cursorId is undefined' , async ( ) => {
201+ const getMoreOperation = new GetMoreOperation (
202+ ns ( 'db.collection' ) ,
203+ // @ts -expect-error: Testing undefined cursorId
204+ undefined ,
205+ server ,
206+ options
207+ ) ;
208+ const error = await promisify ( getMoreOperation . execute . bind ( getMoreOperation ) ) (
209+ server ,
210+ undefined
211+ ) . catch ( error => error ) ;
212+ expect ( error ) . to . be . instanceOf ( MongoRuntimeError ) ;
213+ } ) ;
214+
215+ it ( 'should throw if the collection is undefined' , async ( ) => {
216+ const getMoreOperation = new GetMoreOperation (
217+ ns ( 'db' ) ,
218+ Long . fromNumber ( 1 ) ,
219+ server ,
220+ options
221+ ) ;
222+ const error = await promisify ( getMoreOperation . execute . bind ( getMoreOperation ) ) (
223+ server ,
224+ undefined
225+ ) . catch ( error => error ) ;
226+ expect ( error ) . to . be . instanceOf ( MongoRuntimeError ) ;
227+ } ) ;
228+
229+ it ( 'should throw if the cursorId is zero' , async ( ) => {
230+ const getMoreOperation = new GetMoreOperation (
231+ ns ( 'db.collection' ) ,
232+ Long . fromNumber ( 0 ) ,
233+ server ,
234+ options
235+ ) ;
236+ const error = await promisify ( getMoreOperation . execute . bind ( getMoreOperation ) ) (
237+ server ,
238+ undefined
239+ ) . catch ( error => error ) ;
240+ expect ( error ) . to . be . instanceOf ( MongoRuntimeError ) ;
241+ } ) ;
242+ } ) ;
195243 } ) ;
196244
197245 describe ( '#hasAspect' , function ( ) {
0 commit comments