Skip to content

Commit 9479093

Browse files
author
Artem
committed
possible fix for ITests. The idea to use quit() instead of disconnect()
1 parent 9d2912c commit 9479093

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

redisinsight/api/src/modules/pub-sub/model/redis-client.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ nodeClient.unsubscribe = jest.fn();
1111
nodeClient.punsubscribe = jest.fn();
1212
nodeClient.status = 'ready';
1313
nodeClient.disconnect = jest.fn();
14+
nodeClient.quit = jest.fn();
1415

1516
describe('RedisClient', () => {
1617
let redisClient: RedisClient;
@@ -126,7 +127,7 @@ describe('RedisClient', () => {
126127
expect(redisClient['client']).toEqual(null);
127128
expect(redisClient['status']).toEqual(RedisClientStatus.End);
128129
expect(removeAllListenersSpy).toHaveBeenCalled();
129-
expect(nodeClient.disconnect).toHaveBeenCalled();
130+
expect(nodeClient.quit).toHaveBeenCalled();
130131
});
131132
});
132133
});

redisinsight/api/src/modules/pub-sub/model/redis-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class RedisClient extends EventEmitter2 {
9595
*/
9696
destroy() {
9797
this.client?.removeAllListeners();
98-
this.client?.disconnect(false);
98+
this.client?.quit();
9999
this.client = null;
100100
this.status = RedisClientStatus.End;
101101
}

redisinsight/api/src/modules/pub-sub/model/user-session.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ nodeClient.unsubscribe = jest.fn();
1616
nodeClient.punsubscribe = jest.fn();
1717
nodeClient.status = 'ready';
1818
nodeClient.disconnect = jest.fn();
19+
nodeClient.quit = jest.fn();
1920

2021
const mockUserClient = new UserClient('socketId', mockSocket, 'databaseId');
2122

@@ -119,7 +120,7 @@ describe('UserSession', () => {
119120
it('should handle message by particular subscription', async () => {
120121
userSession.handleDisconnect();
121122
expect(userSession['subscriptions'].size).toEqual(0);
122-
expect(nodeClient.disconnect).toHaveBeenCalled();
123+
expect(nodeClient.quit).toHaveBeenCalled();
123124
});
124125
});
125126
});

0 commit comments

Comments
 (0)