@@ -30,6 +30,30 @@ describe('Collection (#findOneAnd...)', function () {
30
30
} ) ;
31
31
} ) ;
32
32
33
+ context ( 'when passing includeResultMetadata: false' , function ( ) {
34
+ let client ;
35
+ let collection ;
36
+
37
+ beforeEach ( async function ( ) {
38
+ client = this . configuration . newClient ( { } , { maxPoolSize : 1 } ) ;
39
+ collection = client . db ( 'test' ) . collection ( 'findAndModifyTest' ) ;
40
+ await collection . insertMany ( [ { a : 1 , b : 1 } ] , { writeConcern : { w : 1 } } ) ;
41
+ } ) ;
42
+
43
+ afterEach ( async function ( ) {
44
+ await collection . drop ( ) ;
45
+ await client ?. close ( ) ;
46
+ } ) ;
47
+
48
+ it ( 'returns the deleted document' , async function ( ) {
49
+ const result = await collection . findOneAndDelete (
50
+ { a : 1 } ,
51
+ { includeResultMetadata : false }
52
+ ) ;
53
+ expect ( result . b ) . to . equal ( 1 ) ;
54
+ } ) ;
55
+ } ) ;
56
+
33
57
context ( 'when passing an object id filter' , function ( ) {
34
58
let client ;
35
59
let collection ;
@@ -140,6 +164,31 @@ describe('Collection (#findOneAnd...)', function () {
140
164
} ) ;
141
165
} ) ;
142
166
167
+ context ( 'when passing includeResultMetadata: false' , function ( ) {
168
+ let client ;
169
+ let collection ;
170
+
171
+ beforeEach ( async function ( ) {
172
+ client = this . configuration . newClient ( { } , { maxPoolSize : 1 } ) ;
173
+ collection = client . db ( 'test' ) . collection ( 'findAndModifyTest' ) ;
174
+ await collection . insertMany ( [ { a : 1 , b : 1 } ] , { writeConcern : { w : 1 } } ) ;
175
+ } ) ;
176
+
177
+ afterEach ( async function ( ) {
178
+ await collection . drop ( ) ;
179
+ await client ?. close ( ) ;
180
+ } ) ;
181
+
182
+ it ( 'returns the modified document' , async function ( ) {
183
+ const result = await collection . findOneAndUpdate (
184
+ { a : 1 } ,
185
+ { $set : { a : 1 } } ,
186
+ { includeResultMetadata : false }
187
+ ) ;
188
+ expect ( result . b ) . to . equal ( 1 ) ;
189
+ } ) ;
190
+ } ) ;
191
+
143
192
context ( 'when passing an object id filter' , function ( ) {
144
193
let client ;
145
194
let collection ;
@@ -280,6 +329,31 @@ describe('Collection (#findOneAnd...)', function () {
280
329
} ) ;
281
330
} ) ;
282
331
332
+ context ( 'when passing includeResultMetadata: false' , function ( ) {
333
+ let client ;
334
+ let collection ;
335
+
336
+ beforeEach ( async function ( ) {
337
+ client = this . configuration . newClient ( { } , { maxPoolSize : 1 } ) ;
338
+ collection = client . db ( 'test' ) . collection ( 'findAndModifyTest' ) ;
339
+ await collection . insertMany ( [ { a : 1 , b : 1 } ] , { writeConcern : { w : 1 } } ) ;
340
+ } ) ;
341
+
342
+ afterEach ( async function ( ) {
343
+ await collection . drop ( ) ;
344
+ await client ?. close ( ) ;
345
+ } ) ;
346
+
347
+ it ( 'returns the replaced document' , async function ( ) {
348
+ const result = await collection . findOneAndReplace (
349
+ { a : 1 } ,
350
+ { a : 1 } ,
351
+ { includeResultMetadata : false }
352
+ ) ;
353
+ expect ( result . b ) . to . equal ( 1 ) ;
354
+ } ) ;
355
+ } ) ;
356
+
283
357
context ( 'when passing an object id filter' , function ( ) {
284
358
let client ;
285
359
let collection ;
0 commit comments