forked from parse-community/parse-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRedisPubSub.spec.js
42 lines (36 loc) · 1.09 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
const RedisPubSub = require('../lib/Adapters/PubSub/RedisPubSub').RedisPubSub;
describe('RedisPubSub', function () {
beforeEach(function (done) {
// Mock redis
const createClient = jasmine.createSpy('createClient');
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');
});
});