-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
Copy pathRedisPubSub.spec.js
45 lines (39 loc) · 1.21 KB
/
RedisPubSub.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const RedisPubSub = require('../lib/Adapters/PubSub/RedisPubSub').RedisPubSub;
describe('RedisPubSub', function () {
beforeEach(function (done) {
// Mock redis
const createClient = jasmine.createSpy('createClient').and.returnValue({
connect: jasmine.createSpy('connect').and.resolveTo(),
on: jasmine.createSpy('on'),
});
jasmine.mockLibrary('redis', 'createClient', createClient);
done();
});
it('can create publisher', function () {
RedisPubSub.createPublisher({
redisURL: 'redisAddress',
redisOptions: { socket_keepalive: true },
});
const redis = require('redis');
expect(redis.createClient).toHaveBeenCalledWith({
url: 'redisAddress',
socket_keepalive: true,
no_ready_check: true,
});
});
it('can create subscriber', function () {
RedisPubSub.createSubscriber({
redisURL: 'redisAddress',
redisOptions: { socket_keepalive: true },
});
const redis = require('redis');
expect(redis.createClient).toHaveBeenCalledWith({
url: 'redisAddress',
socket_keepalive: true,
no_ready_check: true,
});
});
afterEach(function () {
jasmine.restoreLibrary('redis', 'createClient');
});
});