@@ -21,6 +21,7 @@ import neo4j from '../../src/v1';
2121import sharedNeo4j from '../internal/shared-neo4j' ;
2222import FakeConnection from '../internal/fake-connection' ;
2323import lolex from 'lolex' ;
24+ import { DEFAULT_ACQUISITION_TIMEOUT , DEFAULT_MAX_SIZE } from '../../src/v1/internal/pool-config' ;
2425
2526describe ( 'driver' , ( ) => {
2627
@@ -191,13 +192,10 @@ describe('driver', () => {
191192 expect ( ( ) => neo4j . driver ( 'bolt://localhost:7687/?policy=my_policy' ) ) . toThrow ( ) ;
192193 } ) ;
193194
194- it ( 'should sanitize maxConnectionLifetime in the config' , ( ) => {
195- validateMaxConnectionLifetime ( { } , null ) ;
196- validateMaxConnectionLifetime ( { maxConnectionLifetime : 42 } , 42 ) ;
197- validateMaxConnectionLifetime ( { maxConnectionLifetime : 0 } , null ) ;
198- validateMaxConnectionLifetime ( { maxConnectionLifetime : '42' } , 42 ) ;
199- validateMaxConnectionLifetime ( { maxConnectionLifetime : '042' } , 42 ) ;
200- validateMaxConnectionLifetime ( { maxConnectionLifetime : - 42 } , null ) ;
195+ it ( 'should sanitize pool setting values in the config' , ( ) => {
196+ testConfigSanitizing ( 'maxConnectionLifetime' , 60 * 60 * 1000 ) ;
197+ testConfigSanitizing ( 'maxConnectionPoolSize' , DEFAULT_MAX_SIZE ) ;
198+ testConfigSanitizing ( 'connectionAcquisitionTimeout' , DEFAULT_ACQUISITION_TIMEOUT ) ;
201199 } ) ;
202200
203201 it ( 'should treat closed connections as invalid' , ( ) => {
@@ -321,10 +319,19 @@ describe('driver', () => {
321319 return neo4j . auth . basic ( 'neo4j' , 'who would use such a password' ) ;
322320 }
323321
324- function validateMaxConnectionLifetime ( config , expectedValue ) {
322+ function testConfigSanitizing ( configProperty , defaultValue ) {
323+ validateConfigSanitizing ( { } , defaultValue ) ;
324+ validateConfigSanitizing ( { [ configProperty ] : 42 } , 42 ) ;
325+ validateConfigSanitizing ( { [ configProperty ] : 0 } , 0 ) ;
326+ validateConfigSanitizing ( { [ configProperty ] : '42' } , 42 ) ;
327+ validateConfigSanitizing ( { [ configProperty ] : '042' } , 42 ) ;
328+ validateConfigSanitizing ( { [ configProperty ] : - 42 } , Number . MAX_SAFE_INTEGER ) ;
329+ }
330+
331+ function validateConfigSanitizing ( config , configProperty , expectedValue ) {
325332 const driver = neo4j . driver ( 'bolt://localhost' , sharedNeo4j . authToken , config ) ;
326333 try {
327- expect ( driver . _config . maxConnectionLifetime ) . toEqual ( expectedValue ) ;
334+ expect ( driver . _config [ configProperty ] ) . toEqual ( expectedValue ) ;
328335 } finally {
329336 driver . close ( ) ;
330337 }
0 commit comments