2018-07-02 23:30:14 -04:00
|
|
|
const RedisPubSub = require('../lib/Adapters/PubSub/RedisPubSub').RedisPubSub;
|
2016-03-10 14:27:00 -08:00
|
|
|
|
|
|
|
|
describe('RedisPubSub', function() {
|
|
|
|
|
beforeEach(function(done) {
|
|
|
|
|
// Mock redis
|
2018-02-17 09:55:30 -05:00
|
|
|
const createClient = jasmine.createSpy('createClient');
|
2016-03-10 14:27:00 -08:00
|
|
|
jasmine.mockLibrary('redis', 'createClient', createClient);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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');
|
2018-09-01 13:58:06 -04:00
|
|
|
expect(redis.createClient).toHaveBeenCalledWith('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
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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');
|
2018-09-01 13:58:06 -04:00
|
|
|
expect(redis.createClient).toHaveBeenCalledWith('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
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
|
jasmine.restoreLibrary('redis', 'createClient');
|
|
|
|
|
});
|
|
|
|
|
});
|