@@ -44,6 +44,16 @@ describe('DirectConnectionProvider', () => {
4444 } ) ;
4545 } ) ;
4646
47+ it ( 'returns an initialized connection' , done => {
48+ const pool = newPool ( ) ;
49+ const connectionProvider = newDirectConnectionProvider ( 'localhost:123' , pool ) ;
50+
51+ connectionProvider . acquireConnection ( READ ) . then ( connection => {
52+ expect ( connection . initialized ) . toBeTruthy ( ) ;
53+ done ( ) ;
54+ } ) ;
55+ } ) ;
56+
4757} ) ;
4858
4959describe ( 'LoadBalancer' , ( ) => {
@@ -1049,6 +1059,26 @@ describe('LoadBalancer', () => {
10491059 } ) ;
10501060 } ) ;
10511061
1062+ it ( 'returns an initialized connection' , done => {
1063+ const pool = newPool ( ) ;
1064+ const loadBalancer = newLoadBalancer (
1065+ [ 'server-1' , 'server-2' ] ,
1066+ [ 'server-3' , 'server-4' ] ,
1067+ [ 'server-5' , 'server-6' ] ,
1068+ pool
1069+ ) ;
1070+
1071+ loadBalancer . acquireConnection ( READ ) . then ( connection => {
1072+ expect ( connection . initialized ) . toBeTruthy ( ) ;
1073+
1074+ loadBalancer . acquireConnection ( WRITE ) . then ( connection => {
1075+ expect ( connection . initialized ) . toBeTruthy ( ) ;
1076+
1077+ done ( ) ;
1078+ } ) ;
1079+ } ) ;
1080+ } ) ;
1081+
10521082} ) ;
10531083
10541084function newDirectConnectionProvider ( address , pool ) {
@@ -1126,13 +1156,15 @@ class FakeConnection {
11261156 constructor ( address , release ) {
11271157 this . address = address ;
11281158 this . release = release ;
1159+ this . initialized = false ;
11291160 }
11301161
11311162 static create ( address , release ) {
11321163 return new FakeConnection ( address , release ) ;
11331164 }
11341165
11351166 initializationCompleted ( ) {
1167+ this . initialized = true ;
11361168 return Promise . resolve ( this ) ;
11371169 }
11381170}
0 commit comments