@@ -18,6 +18,7 @@ assert.equal(mainExport, createConnection);
18
18
19
19
var doneCalled = false ;
20
20
var exceptionCaught = false ;
21
+ var doneEventsConnect = false ;
21
22
22
23
var doneCalledPool = false ;
23
24
var exceptionCaughtPool = false ;
@@ -103,6 +104,38 @@ function testObjParams() {
103
104
} ) ;
104
105
}
105
106
107
+ function testEventsConnect ( ) {
108
+ var connPromise = createConnection ( config ) . then ( function ( conn ) {
109
+ var events = 0 ;
110
+
111
+ conn
112
+ . once ( 'error' , function ( connection ) {
113
+ ++ events ;
114
+ } )
115
+ . once ( 'drain' , function ( connection ) {
116
+ ++ events ;
117
+ } )
118
+ . once ( 'connect' , function ( ) {
119
+ ++ events ;
120
+ } )
121
+ . once ( 'enqueue' , function ( ) {
122
+ ++ events ;
123
+ } )
124
+ . once ( 'end' , function ( ) {
125
+ ++ events ;
126
+
127
+ doneEventsConnect = events === 5 ;
128
+ } ) ;
129
+
130
+ conn . connection . emit ( 'error' ) ;
131
+ conn . connection . emit ( 'drain' ) ;
132
+ conn . connection . emit ( 'connect' ) ;
133
+ conn . connection . emit ( 'enqueue' ) ;
134
+ conn . connection . emit ( 'end' ) ;
135
+ conn . end ( ) ;
136
+ } ) ;
137
+ }
138
+
106
139
function testBasicPool ( ) {
107
140
var pool = createPool ( config ) ;
108
141
pool
@@ -193,6 +226,7 @@ function testEventsPool() {
193
226
testBasic ( ) ;
194
227
testErrors ( ) ;
195
228
testObjParams ( ) ;
229
+ testEventsConnect ( ) ;
196
230
testBasicPool ( ) ;
197
231
testErrorsPool ( ) ;
198
232
testObjParamsPool ( ) ;
@@ -204,6 +238,7 @@ process.on('exit', function() {
204
238
}
205
239
assert . equal ( doneCalled , true ) ;
206
240
assert . equal ( exceptionCaught , true ) ;
241
+ assert . equal ( doneEventsConnect , true ) ;
207
242
assert . equal ( doneCalledPool , true ) ;
208
243
assert . equal ( exceptionCaughtPool , true ) ;
209
244
assert . equal ( doneEventsPool , true ) ;
0 commit comments