@@ -129,6 +129,7 @@ describe('ChannelConnection', () => {
129
129
describe ( '._handleFatalError()' , ( ) => {
130
130
describe ( 'when there is not current failure on going' , ( ) => {
131
131
const thrownError = newError ( 'some error' , 'C' )
132
+ let loggerFunction ;
132
133
let notifyFatalError ;
133
134
let connection ;
134
135
@@ -138,9 +139,10 @@ describe('ChannelConnection', () => {
138
139
notifyFatalError,
139
140
currentFailure : null
140
141
}
141
-
142
+ loggerFunction = jest . fn ( )
143
+ const logger = new Logger ( 'info' , loggerFunction )
142
144
const protocolSupplier = ( ) => protocol
143
- connection = spyOnConnectionChannel ( { protocolSupplier } )
145
+ connection = spyOnConnectionChannel ( { protocolSupplier, logger } )
144
146
} )
145
147
146
148
it ( 'should set connection state to broken' , ( ) => {
@@ -160,11 +162,22 @@ describe('ChannelConnection', () => {
160
162
161
163
expect ( notifyFatalError ) . toHaveBeenCalledWith ( thrownError )
162
164
} )
165
+
166
+ it ( 'should log the thrownError' , ( ) => {
167
+ connection . _handleFatalError ( thrownError )
168
+
169
+ expect ( loggerFunction ) . toHaveBeenCalledWith (
170
+ 'error' ,
171
+ `${ connection } experienced a fatal error caused by Neo4jError: some error ` +
172
+ '({"code":"C","name":"Neo4jError"})'
173
+ )
174
+ } )
163
175
} )
164
176
165
177
describe ( 'when there is current failure on going' , ( ) => {
166
178
const thrownError = newError ( 'some error' , 'C' )
167
179
const currentFailure = newError ( 'current failure' , 'ongoing' )
180
+ let loggerFunction ;
168
181
let notifyFatalError ;
169
182
let connection ;
170
183
@@ -174,9 +187,10 @@ describe('ChannelConnection', () => {
174
187
notifyFatalError,
175
188
currentFailure
176
189
}
177
-
190
+ loggerFunction = jest . fn ( )
191
+ const logger = new Logger ( 'info' , loggerFunction )
178
192
const protocolSupplier = ( ) => protocol
179
- connection = spyOnConnectionChannel ( { protocolSupplier } )
193
+ connection = spyOnConnectionChannel ( { protocolSupplier, logger } )
180
194
} )
181
195
182
196
it ( 'should set connection state to broken' , ( ) => {
@@ -196,6 +210,16 @@ describe('ChannelConnection', () => {
196
210
197
211
expect ( notifyFatalError ) . toHaveBeenCalledWith ( currentFailure )
198
212
} )
213
+
214
+ it ( 'should log the currentFailure' , ( ) => {
215
+ connection . _handleFatalError ( thrownError )
216
+
217
+ expect ( loggerFunction ) . toHaveBeenCalledWith (
218
+ 'error' ,
219
+ `${ connection } experienced a fatal error caused by Neo4jError: current failure ` +
220
+ '({"code":"ongoing","name":"Neo4jError"})'
221
+ )
222
+ } )
199
223
} )
200
224
} )
201
225
0 commit comments