test-countSubscriptions.js 834 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. var PubSub = require('../src/pubsub'),
  3. TestHelper = require('./helper'),
  4. assert = require('referee').assert,
  5. sinon = require('sinon');
  6. describe('test-countSubscriptions method', function () {
  7. it('must be count eq 0', function () {
  8. var topic = TestHelper.getUniqueString(),
  9. spy1 = sinon.spy();
  10. PubSub.subscribe(topic, spy1);
  11. var counts = PubSub.countSubscriptions(topic);
  12. assert.equals(counts,1);
  13. });
  14. it('should count all subscriptions', function() {
  15. var topic = TestHelper.getUniqueString(),
  16. spy1 = sinon.spy(),
  17. spy2 = sinon.spy();
  18. PubSub.subscribe(topic, spy1);
  19. PubSub.subscribe(topic, spy2);
  20. var counts = PubSub.countSubscriptions(topic);
  21. assert.equals(counts, 2);
  22. });
  23. });