@@ -29,6 +29,9 @@ describe('Changestream Examples', function() {
29
29
if ( err ) return console . log ( err ) ;
30
30
expect ( err ) . to . equal ( null ) ;
31
31
expect ( next ) . to . exist ;
32
+
33
+ // Since changeStream has an implicit seession,
34
+ // we need to close the changeStream for unit testing purposes
32
35
changeStream . close ( ) ;
33
36
client . close ( ) ;
34
37
done ( ) ;
@@ -67,6 +70,9 @@ describe('Changestream Examples', function() {
67
70
const changeStream = collection . watch ( ) ;
68
71
changeStream . on ( 'change' , function ( change ) {
69
72
expect ( change ) . to . exist ;
73
+
74
+ // Since changeStream has an implicit seession,
75
+ // we need to close the changeStream for unit testing purposes
70
76
changeStream . close ( ) ;
71
77
client . close ( ) ;
72
78
done ( ) ;
@@ -102,6 +108,9 @@ describe('Changestream Examples', function() {
102
108
103
109
changeStream . stream ( { transform : JSON . stringify } ) . once ( 'data' , function ( chunk ) {
104
110
expect ( chunk ) . to . exist ;
111
+
112
+ // Since changeStream has an implicit seession,
113
+ // we need to close the changeStream for unit testing purposes
105
114
changeStream . close ( ) ;
106
115
client . close ( ) ;
107
116
done ( ) ;
@@ -138,6 +147,9 @@ describe('Changestream Examples', function() {
138
147
const changeStream = collection . watch ( { fullDocument : 'updateLookup' } ) ;
139
148
changeStream . on ( 'change' , function ( change ) {
140
149
expect ( change ) . to . exist ;
150
+
151
+ // Since changeStream has an implicit seession,
152
+ // we need to close the changeStream for unit testing purposes
141
153
changeStream . close ( ) ;
142
154
client . close ( ) ;
143
155
done ( ) ;
@@ -196,6 +208,9 @@ describe('Changestream Examples', function() {
196
208
if ( err ) return console . log ( err ) ;
197
209
expect ( err ) . to . equal ( null ) ;
198
210
expect ( next ) . to . exist ;
211
+
212
+ // Since changeStream has an implicit seession,
213
+ // we need to close the changeStream for unit testing purposes
199
214
newChangeStream . close ( ) ;
200
215
client . close ( ) ;
201
216
done ( ) ;
@@ -245,6 +260,8 @@ describe('Changestream Examples', function() {
245
260
expect ( next . newField ) . to . exist ;
246
261
expect ( next . newField ) . to . equal ( 'this is an added field!' ) ;
247
262
263
+ // Since changeStream has an implicit seession,
264
+ // we need to close the changeStream for unit testing purposes
248
265
changeStream . close ( ) ;
249
266
client . close ( ) ;
250
267
done ( ) ;
0 commit comments