2018-07-02 23:30:14 -04:00
|
|
|
const RedisPubSub = require('../lib/Adapters/PubSub/RedisPubSub').RedisPubSub;
|
2016-03-10 14:27:00 -08:00
|
|
|
|
2020-10-25 15:06:58 -05:00
|
|
|
describe('RedisPubSub', function () {
|
|
|
|
|
beforeEach(function (done) {
|
2016-03-10 14:27:00 -08:00
|
|
|
// Mock redis
|
2025-02-24 03:48:34 +02:00
|
|
|
const createClient = jasmine.createSpy('createClient').and.returnValue({
|
|
|
|
|
connect: jasmine.createSpy('connect').and.resolveTo(),
|
|
|
|
|
on: jasmine.createSpy('on'),
|
|
|
|
|
});
|
2016-03-10 14:27:00 -08:00
|
|
|
jasmine.mockLibrary('redis', 'createClient', createClient);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
2020-10-25 15:06:58 -05:00
|
|
|
it('can create publisher', function () {
|
2019-05-11 19:13:41 -05:00
|
|
|
RedisPubSub.createPublisher({
|
|
|
|
|
redisURL: 'redisAddress',
|
|
|
|
|
redisOptions: { socket_keepalive: true },
|
|
|
|
|
});
|
2016-03-10 14:27:00 -08:00
|
|
|
|
2018-02-17 09:55:30 -05:00
|
|
|
const redis = require('redis');
|
2022-11-27 03:45:30 +11:00
|
|
|
expect(redis.createClient).toHaveBeenCalledWith({
|
|
|
|
|
url: 'redisAddress',
|
2019-05-11 19:13:41 -05:00
|
|
|
socket_keepalive: true,
|
2018-09-01 13:58:06 -04:00
|
|
|
no_ready_check: true,
|
|
|
|
|
});
|
2016-03-10 14:27:00 -08:00
|
|
|
});
|
|
|
|
|
|
2020-10-25 15:06:58 -05:00
|
|
|
it('can create subscriber', function () {
|
2019-05-11 19:13:41 -05:00
|
|
|
RedisPubSub.createSubscriber({
|
|
|
|
|
redisURL: 'redisAddress',
|
|
|
|
|
redisOptions: { socket_keepalive: true },
|
|
|
|
|
});
|
2016-03-10 14:27:00 -08:00
|
|
|
|
2018-02-17 09:55:30 -05:00
|
|
|
const redis = require('redis');
|
2022-11-27 03:45:30 +11:00
|
|
|
expect(redis.createClient).toHaveBeenCalledWith({
|
|
|
|
|
url: 'redisAddress',
|
2019-05-11 19:13:41 -05:00
|
|
|
socket_keepalive: true,
|
2018-09-01 13:58:06 -04:00
|
|
|
no_ready_check: true,
|
|
|
|
|
});
|
2016-03-10 14:27:00 -08:00
|
|
|
});
|
|
|
|
|
|
2020-10-25 15:06:58 -05:00
|
|
|
afterEach(function () {
|
2016-03-10 14:27:00 -08:00
|
|
|
jasmine.restoreLibrary('redis', 'createClient');
|
|
|
|
|
});
|
|
|
|
|
});
|