test-subscribeAll.js 719 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. var PubSub = require('../src/pubsub'),
  3. TestHelper = require('../test/helper'),
  4. assert = require('referee').assert,
  5. sinon = require('sinon');
  6. describe( 'subscribeAll method', function() {
  7. it('should return token as String', function(){
  8. var func = function(){ return undefined; },
  9. token = PubSub.subscribeAll( func );
  10. assert.isString( token );
  11. });
  12. it('should subscribe for all messages', function() {
  13. var message = TestHelper.getUniqueString(),
  14. subscribeFn = sinon.spy();
  15. PubSub.subscribeAll( subscribeFn );
  16. PubSub.publishSync( message, 'some payload' );
  17. assert( subscribeFn.calledOnce );
  18. });
  19. } );