@@ -1113,7 +1113,7 @@ describe('CRUD Prose Spec Tests', () => {
11131113 let maxBsonObjectSize ;
11141114 let maxMessageSizeBytes ;
11151115 let numModels ;
1116- const models : AnyClientBulkWriteModel [ ] = [ ] ;
1116+ let models : AnyClientBulkWriteModel [ ] = [ ] ;
11171117 const commands : CommandStartedEvent [ ] = [ ] ;
11181118
11191119 beforeEach ( async function ( ) {
@@ -1122,20 +1122,24 @@ describe('CRUD Prose Spec Tests', () => {
11221122 } ) ;
11231123 client = this . configuration . newClient ( uri , { monitorCommands : true } ) ;
11241124 await client . connect ( ) ;
1125- await client . db ( 'db' ) . collection ( 'coll' ) . drop ( ) ;
1125+ await client
1126+ . db ( 'db' )
1127+ . collection ( 'coll' )
1128+ . drop ( )
1129+ . catch ( ( ) => null ) ;
11261130 await client . db ( 'db' ) . createCollection ( 'coll' ) ;
11271131 const hello = await client . db ( 'admin' ) . command ( { hello : 1 } ) ;
11281132 maxBsonObjectSize = hello . maxBsonObjectSize ;
11291133 maxMessageSizeBytes = hello . maxMessageSizeBytes ;
11301134 numModels = Math . floor ( maxMessageSizeBytes / maxBsonObjectSize ) + 1 ;
1131- Array . from ( { length : numModels } , ( ) => {
1132- models . push ( {
1135+ models = Array . from ( { length : numModels } , ( ) => {
1136+ return {
11331137 name : 'insertOne' ,
11341138 namespace : 'db.coll' ,
11351139 document : {
11361140 a : 'b' . repeat ( maxBsonObjectSize - 500 )
11371141 }
1138- } ) ;
1142+ } ;
11391143 } ) ;
11401144
11411145 client . on ( 'commandStarted' , filterForCommands ( 'bulkWrite' , commands ) ) ;
@@ -1157,7 +1161,7 @@ describe('CRUD Prose Spec Tests', () => {
11571161 expect ( commands [ 1 ] . command . ops . length ) . to . equal ( 1 ) ;
11581162 expect ( commands [ 1 ] . command . writeConcern . w ) . to . equal ( 0 ) ;
11591163 const count = await client . db ( 'db' ) . collection ( 'coll' ) . countDocuments ( ) ;
1160- expect ( count ) . to . equal ( 3 ) ;
1164+ expect ( count ) . to . equal ( numModels ) ;
11611165 }
11621166 } ) ;
11631167 } ) ;
0 commit comments