@@ -71,10 +71,8 @@ maybeDescribe('examples(change-stream):', function () {
71
71
} ) ;
72
72
// End Changestream Example 1
73
73
74
- // Start Changestream Example 1 Alternative
75
74
const changeStreamIterator = collection . watch ( ) ;
76
75
const next = await changeStreamIterator . next ( ) ;
77
- // End Changestream Example 1 Alternative
78
76
79
77
await changeStream . close ( ) ;
80
78
await changeStreamIterator . close ( ) ;
@@ -84,6 +82,25 @@ maybeDescribe('examples(change-stream):', function () {
84
82
}
85
83
} ) ;
86
84
85
+ it ( 'Open A Change Stream and use iteration methods' , {
86
+ metadata : { requires : { topology : [ 'replicaset' ] , mongodb : '>=3.6.0' } } ,
87
+ test : async function ( ) {
88
+ const looper = new Looper ( ( ) => db . collection ( 'inventory' ) . insertOne ( { a : 1 } ) ) ;
89
+ looper . run ( ) ;
90
+
91
+ // Start Changestream Example 1 Alternative
92
+ const collection = db . collection ( 'inventory' ) ;
93
+ const changeStream = collection . watch ( ) ;
94
+ const next = await changeStream . next ( ) ;
95
+ // End Changestream Example 1 Alternative
96
+
97
+ await changeStream . close ( ) ;
98
+ await looper . stop ( ) ;
99
+
100
+ expect ( next ) . to . have . property ( 'operationType' ) . that . equals ( 'insert' ) ;
101
+ }
102
+ } ) ;
103
+
87
104
it ( 'Lookup Full Document for Update Operations' , {
88
105
metadata : { requires : { topology : [ 'replicaset' ] , mongodb : '>=3.6.0' } } ,
89
106
test : async function ( ) {
0 commit comments