@@ -214,7 +214,7 @@ describe('class MongoClient', function () {
214214 spy . restore ( ) ;
215215 } ) ;
216216
217- it ( 'sets the option to 0' , {
217+ it ( 'the Node.js runtime sets the option to 0' , {
218218 metadata : { requires : { apiVersion : false } } ,
219219 test : function ( ) {
220220 expect ( spy ) . to . have . been . calledWith (
@@ -226,6 +226,34 @@ describe('class MongoClient', function () {
226226 }
227227 } ) ;
228228 } ) ;
229+
230+ context ( 'when the value is mistyped' , function ( ) {
231+ // Set server selection timeout to get the error quicker.
232+ const options = { keepAliveInitialDelay : 'test' , serverSelectionTimeoutMS : 1000 } ;
233+ let client ;
234+ let spy ;
235+
236+ beforeEach ( async function ( ) {
237+ spy = sinon . spy ( net , 'createConnection' ) ;
238+ const uri = this . configuration . url ( ) ;
239+ client = new MongoClient ( uri , options ) ;
240+ } ) ;
241+
242+ afterEach ( async function ( ) {
243+ await client ?. close ( ) ;
244+ spy . restore ( ) ;
245+ } ) ;
246+
247+ it ( 'throws an error' , {
248+ metadata : { requires : { apiVersion : false } } ,
249+ test : async function ( ) {
250+ const error = await client . connect ( ) . catch ( error => error ) ;
251+ expect ( error . message ) . to . include (
252+ 'property must be of type number. Received type string'
253+ ) ;
254+ }
255+ } ) ;
256+ } ) ;
229257 } ) ;
230258
231259 context ( 'when keepAliveInitialDelay is not provided' , function ( ) {
0 commit comments