@@ -451,10 +451,6 @@ describe('Find Cursor', function () {
451451 resolve ( v ) ;
452452 } ) ;
453453
454- stream . once ( 'end' , v => {
455- resolve ( v ) ;
456- } ) ;
457-
458454 stream . once ( 'error' , v => {
459455 reject ( v ) ;
460456 } ) ;
@@ -476,10 +472,6 @@ describe('Find Cursor', function () {
476472 resolve ( v ) ;
477473 } ) ;
478474
479- stream . once ( 'end' , v => {
480- resolve ( v ) ;
481- } ) ;
482-
483475 stream . once ( 'error' , v => {
484476 reject ( v ) ;
485477 } ) ;
@@ -502,10 +494,6 @@ describe('Find Cursor', function () {
502494 resolve ( v ) ;
503495 } ) ;
504496
505- stream . once ( 'end' , v => {
506- resolve ( v ) ;
507- } ) ;
508-
509497 stream . once ( 'error' , v => {
510498 reject ( v ) ;
511499 } ) ;
@@ -578,10 +566,10 @@ describe('Find Cursor', function () {
578566 await cursor . toArray ( ) ;
579567
580568 const s = cursor . stream ( ) ;
581- const { promise, resolve } = promiseWithResolvers ( ) ;
569+ const { promise, resolve, reject } = promiseWithResolvers ( ) ;
582570
583571 s . once ( 'data' , d => {
584- resolve ( d ) ;
572+ reject ( d ) ;
585573 } ) ;
586574
587575 s . once ( 'end' , d => {
@@ -650,95 +638,6 @@ describe('Find Cursor', function () {
650638 } ) ;
651639 } ) ;
652640
653- context ( 'when cursor.next() is called after cursor.stream()' , function ( ) {
654- it ( 'throws a MongoExpiredSessionError' , async function ( ) {
655- cursor = collection . find ( { } , { batchSize : 1 } ) ;
656-
657- const stream = cursor . stream ( ) ;
658- const { promise, resolve, reject } = promiseWithResolvers ( ) ;
659-
660- stream . once ( 'data' , v => {
661- resolve ( v ) ;
662- } ) ;
663-
664- stream . once ( 'end' , v => {
665- resolve ( v ) ;
666- } ) ;
667-
668- stream . once ( 'error' , v => {
669- reject ( v ) ;
670- } ) ;
671- await promise ;
672-
673- const maybeError = await cursor . next ( ) . then (
674- ( ) => null ,
675- e => e
676- ) ;
677-
678- expect ( maybeError ) . to . be . instanceof ( MongoExpiredSessionError ) ;
679- } ) ;
680- } ) ;
681-
682- context ( 'when cursor.tryNext() is called after cursor.stream()' , function ( ) {
683- it ( 'throws a MongoExpiredSessionError' , async function ( ) {
684- cursor = collection . find ( { } , { batchSize : 1 } ) ;
685-
686- const stream = cursor . stream ( ) ;
687- const { promise, resolve, reject } = promiseWithResolvers ( ) ;
688-
689- stream . once ( 'data' , v => {
690- resolve ( v ) ;
691- } ) ;
692-
693- stream . once ( 'end' , v => {
694- resolve ( v ) ;
695- } ) ;
696-
697- stream . once ( 'error' , v => {
698- reject ( v ) ;
699- } ) ;
700- await promise ;
701-
702- const maybeError = await cursor . tryNext ( ) . then (
703- ( ) => null ,
704- e => e
705- ) ;
706-
707- expect ( maybeError ) . to . be . instanceof ( MongoExpiredSessionError ) ;
708- } ) ;
709- } ) ;
710-
711- context ( 'when cursor.[Symbol.asyncIterator] is called after cursor.stream()' , function ( ) {
712- it ( 'throws a MongoExpiredSessionError' , async function ( ) {
713- cursor = collection . find ( { } , { batchSize : 1 } ) ;
714-
715- const stream = cursor . stream ( ) ;
716- const { promise, resolve, reject } = promiseWithResolvers ( ) ;
717-
718- stream . once ( 'data' , v => {
719- resolve ( v ) ;
720- } ) ;
721-
722- stream . once ( 'end' , v => {
723- resolve ( v ) ;
724- } ) ;
725-
726- stream . once ( 'error' , v => {
727- reject ( v ) ;
728- } ) ;
729- await promise ;
730-
731- try {
732- // eslint-disable-next-line no-unused-vars, no-empty
733- for await ( const _ of cursor ) {
734- }
735- expect . fail ( 'expected to throw' ) ;
736- } catch ( err ) {
737- expect ( err ) . to . be . instanceof ( MongoExpiredSessionError ) ;
738- }
739- } ) ;
740- } ) ;
741-
742641 context ( 'when cursor.readBufferedDocuments() is called after cursor.next()' , function ( ) {
743642 it ( 'returns an empty array' , async function ( ) {
744643 cursor = collection . find ( { } , { batchSize : 1 } ) ;
@@ -795,10 +694,10 @@ describe('Find Cursor', function () {
795694 await cursor . toArray ( ) ;
796695
797696 const s = cursor . stream ( ) ;
798- const { promise, resolve } = promiseWithResolvers ( ) ;
697+ const { promise, resolve, reject } = promiseWithResolvers ( ) ;
799698
800699 s . once ( 'data' , d => {
801- resolve ( d ) ;
700+ reject ( d ) ;
802701 } ) ;
803702
804703 s . once ( 'end' , d => {
0 commit comments