@@ -190,8 +190,12 @@ describe('ClientRedis', () => {
190
190
beforeEach ( ( ) => {
191
191
pubClose = sinon . spy ( ) ;
192
192
subClose = sinon . spy ( ) ;
193
- pub = { quit : pubClose } ;
194
- sub = { quit : subClose } ;
193
+ pub = {
194
+ quit : pubClose ,
195
+ } ;
196
+ sub = {
197
+ quit : subClose ,
198
+ } ;
195
199
untypedClient . pubClient = pub ;
196
200
untypedClient . subClient = sub ;
197
201
} ) ;
@@ -213,6 +217,36 @@ describe('ClientRedis', () => {
213
217
await client . close ( ) ;
214
218
expect ( subClose . called ) . to . be . false ;
215
219
} ) ;
220
+ it . only ( 'should have isManuallyClosed set to true when "end" event is handled during close' , async ( ) => {
221
+ let endHandler : Function | undefined ;
222
+ sub . on = ( event , handler ) => {
223
+ if ( event === 'end' ) endHandler = handler ;
224
+ } ;
225
+ sub . quit = async ( ) => {
226
+ if ( endHandler ) {
227
+ endHandler ( ) ;
228
+ expect ( untypedClient . isManuallyClosed ) . to . be . true ;
229
+ }
230
+ } ;
231
+ client . registerEndListener ( sub ) ;
232
+ await client . close ( ) ;
233
+ } ) ;
234
+
235
+ it . only ( 'should not log error when "end" event is handled during close' , async ( ) => {
236
+ let endHandler : Function | undefined ;
237
+ const logError = sinon . spy ( untypedClient . logger , 'error' ) ;
238
+ sub . on = ( event , handler ) => {
239
+ if ( event === 'end' ) endHandler = handler ;
240
+ } ;
241
+ sub . quit = async ( ) => {
242
+ if ( endHandler ) {
243
+ endHandler ( ) ;
244
+ }
245
+ } ;
246
+ client . registerEndListener ( sub ) ;
247
+ await client . close ( ) ;
248
+ expect ( logError . called ) . to . be . false ;
249
+ } ) ;
216
250
} ) ;
217
251
describe ( 'connect' , ( ) => {
218
252
let createClientSpy : sinon . SinonSpy ;
0 commit comments