@@ -5,13 +5,6 @@ import { expect } from 'chai';
55import { bufferFromHexArray } from './tools/utils' ;
66import { isBufferOrUint8Array } from './tools/utils' ;
77
8- declare module '../register-bson' {
9- interface ObjectId {
10- pool : Uint8Array ;
11- offset : number ;
12- }
13- }
14-
158describe ( 'ObjectId' , function ( ) {
169 describe ( 'static createFromTime()' , ( ) => {
1710 it ( 'creates an objectId with user defined value in the timestamp field' , function ( ) {
@@ -325,11 +318,24 @@ describe('ObjectId', function () {
325318 ObjectId . poolSize = oldPoolSize ;
326319 } ) ;
327320
328- it ( 'should not allow 0 poolSize' , function ( ) {
321+ it ( 'should default to poolSize = 1 when invalid poolSize set ' , function ( ) {
329322 const oldPoolSize = ObjectId . poolSize ;
330- expect ( ( ) => {
331- ObjectId . poolSize = 0 ;
332- } ) . to . throw ( BSONError ) ;
323+
324+ ObjectId . poolSize = 0 ;
325+ expect ( ObjectId . poolSize ) . to . equal ( 1 ) ;
326+ ObjectId . poolSize = - 1 ;
327+ expect ( ObjectId . poolSize ) . to . equal ( 1 ) ;
328+ ObjectId . poolSize = 0n ;
329+ expect ( ObjectId . poolSize ) . to . equal ( 1 ) ;
330+ ObjectId . poolSize = '' ;
331+ expect ( ObjectId . poolSize ) . to . equal ( 1 ) ;
332+ ObjectId . poolSize = NaN ;
333+ expect ( ObjectId . poolSize ) . to . equal ( 1 ) ;
334+ ObjectId . poolSize = { } ;
335+ expect ( ObjectId . poolSize ) . to . equal ( 1 ) ;
336+ ObjectId . poolSize = false ;
337+ expect ( ObjectId . poolSize ) . to . equal ( 1 ) ;
338+ ObjectId . poolSize = '1' ;
333339
334340 ObjectId . poolSize = oldPoolSize ;
335341 } ) ;
0 commit comments