-
-
Notifications
You must be signed in to change notification settings - Fork 459
Expand file tree
/
Copy pathtest-getSubscriptions.js
More file actions
33 lines (24 loc) · 913 Bytes
/
Copy pathtest-getSubscriptions.js
File metadata and controls
33 lines (24 loc) · 913 Bytes
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
'use strict';
var PubSub = require('../src/pubsub'),
TestHelper = require('./helper'),
assert = require('referee').assert,
sinon = require('sinon');
describe('getSubscriptions method', function () {
it('must be length eq 0', function () {
var topic = TestHelper.getUniqueString(),
spy1 = sinon.spy();
PubSub.subscribe(topic, spy1);
var subscriptions = PubSub.getSubscriptions(topic).length;
assert.equals(subscriptions,1);
});
it('should return all subscriptions', function() {
var topic = TestHelper.getUniqueString(),
spy1 = sinon.spy(),
spy2 = sinon.spy();
PubSub.subscribe(topic, spy1);
PubSub.subscribe(topic, spy2);
var subscriptions = PubSub.getSubscriptions(topic);
assert.equals(subscriptions[0], spy1);
assert.equals(subscriptions[1], spy2);
});
});