2018-02-17 09:55:30 -05:00
|
|
|
const RedisPubSub = require('../src/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() {
|
2016-11-24 15:47:41 -05:00
|
|
|
RedisPubSub.createPublisher({redisURL: 'redisAddress'});
|
2016-03-10 14:27:00 -08:00
|
|
|
|
2018-02-17 09:55:30 -05:00
|
|
|
const redis = require('redis');
|
2016-03-10 14:27:00 -08:00
|
|
|
expect(redis.createClient).toHaveBeenCalledWith('redisAddress', { no_ready_check: true });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('can create subscriber', function() {
|
2016-11-24 15:47:41 -05:00
|
|
|
RedisPubSub.createSubscriber({redisURL: 'redisAddress'});
|
2016-03-10 14:27:00 -08:00
|
|
|
|
2018-02-17 09:55:30 -05:00
|
|
|
const redis = require('redis');
|
2016-03-10 14:27:00 -08:00
|
|
|
expect(redis.createClient).toHaveBeenCalledWith('redisAddress', { no_ready_check: true });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
|
jasmine.restoreLibrary('redis', 'createClient');
|
|
|
|
|
});
|
|
|
|
|
});
|