@@ -773,7 +773,7 @@ describe('Change Streams', function () {
773
773
} ) ;
774
774
} ) ;
775
775
776
- describe . only ( 'when close is called while changes are pending' , function ( ) {
776
+ describe ( 'when close is called while changes are pending' , function ( ) {
777
777
let client ;
778
778
let db ;
779
779
let collection : Collection < { insertCount : number } > ;
@@ -825,17 +825,23 @@ describe('Change Streams', function () {
825
825
await changeStream . close ( ) ;
826
826
const results = await Promise . allSettled ( changes ) ;
827
827
828
- for ( const i of changes . keys ( ) ) {
829
- expect ( results )
830
- . to . have . nested . property ( `[${ i } ].reason` )
831
- . that . is . instanceOf ( MongoAPIError ) ;
832
- const message = / C h a n g e S t r e a m i s c l o s e d / i;
833
- expect ( results ) . nested . property ( `[${ i } ].reason` ) . to . match ( message ) ;
834
- }
828
+ const statuses = results . map ( ( { status, reason, value } ) => {
829
+ const res =
830
+ status === 'rejected'
831
+ ? reason . message
832
+ : value . operationType === 'insert'
833
+ ? `insert count = ${ value . fullDocument . insertCount } `
834
+ : null ;
835
+ return `${ status } :${ res } ` ;
836
+ } ) ;
837
+
838
+ expect ( statuses ) . to . deep . equal (
839
+ Array . from ( { length : 20 } , ( ) => 'rejected:ChangeStream is closed' )
840
+ ) ;
835
841
}
836
842
) ;
837
843
838
- it (
844
+ it . skip (
839
845
'rejects promises already returned by next after awaiting the first one' ,
840
846
{ requires : { topology : 'replicaset' } } ,
841
847
async function ( ) {
@@ -847,15 +853,26 @@ describe('Change Streams', function () {
847
853
848
854
const results = await allChanges ;
849
855
850
- const statuses = results . map ( ( { status } ) => status ) ;
856
+ const statuses = results . map ( ( { status, reason, value } ) => {
857
+ const res =
858
+ status === 'rejected'
859
+ ? reason . message
860
+ : value . operationType === 'insert'
861
+ ? `insert count = ${ value . fullDocument . insertCount } `
862
+ : null ;
863
+ return `${ status } :${ res } ` ;
864
+ } ) ;
865
+
866
+ console . log ( statuses ) ;
867
+
851
868
expect ( statuses ) . to . deep . equal ( [
852
- 'fulfilled' ,
853
- ...Array . from ( { length : 19 } , ( ) => 'rejected' )
869
+ 'fulfilled:insert count = 1 ' ,
870
+ ...Array . from ( { length : 19 } , ( ) => 'rejected:ChangeStream is closed ' )
854
871
] ) ;
855
872
}
856
- ) ;
873
+ ) . skipReason = 'TODO(NODE-5221): Parallel change streams and close are nondeterministic' ;
857
874
858
- it (
875
+ it . skip (
859
876
'rejects promises already returned by next after awaiting half of them' ,
860
877
{ requires : { topology : 'replicaset' } } ,
861
878
async function ( ) {
@@ -868,13 +885,24 @@ describe('Change Streams', function () {
868
885
869
886
const results = await allChanges ;
870
887
871
- const statuses = results . map ( ( { status } ) => status ) ;
888
+ const statuses = results . map ( ( { status, reason, value } ) => {
889
+ const res =
890
+ status === 'rejected'
891
+ ? reason . message
892
+ : value . operationType === 'insert'
893
+ ? `insert count = ${ value . fullDocument . insertCount } `
894
+ : null ;
895
+ return `${ status } :${ res } ` ;
896
+ } ) ;
897
+
898
+ console . log ( statuses ) ;
899
+
872
900
expect ( statuses ) . to . deep . equal ( [
873
- ...Array . from ( { length : 10 } , ( ) => 'fulfilled' ) ,
874
- ...Array . from ( { length : 10 } , ( ) => 'rejected ' )
901
+ ...Array . from ( { length : 1 } , ( ) => 'fulfilled:insert count = 0 ' ) ,
902
+ ...Array . from ( { length : 19 } , ( ) => 'fulfilled:insert count = 1 ' )
875
903
] ) ;
876
904
}
877
- ) ;
905
+ ) . skipReason = 'TODO(NODE-5221): Parallel change streams and close are nondeterministic' ;
878
906
} ) ;
879
907
880
908
describe ( 'iterator api' , function ( ) {
0 commit comments