示例#1
0
    it('should add new callback to the existing', function () {
      var eventSystem = SimpleEventSystem();
      eventSystem.register('target1', 'callback1');
      eventSystem.register('target2', 'callback2');

      eventSystem.getCallbacks()['target2'].should.be.eql(['callback2']);
    });
示例#2
0
    it('should call corresponding callback function', function () {
      var eventSystem;
      var callbackObj = {
        'callback': function () {
          return 'test';
        }
      };
      var mock = sinon.mock(callbackObj);
      mock.expects('callback').once().returns('test');

      eventSystem = SimpleEventSystem();
      eventSystem.register('target', callbackObj.callback);

      eventSystem.dispatch('target');

      mock.verify();
      mock.restore();
    });
示例#3
0
  render: function () {
    if (this.state.open) {
      return (
        <div>
          { this.props.children }
        </div>
      );
    }

    return (
      <div></div>
    );
  }
});

Modal.eventSystem = SimpleEventSystem();

Modal.dispatch = function (target, event) {
  return function () {
    Modal.eventSystem.dispatch(target, event);
  };
};

Modal.dispatchFor = function (target) {
  return function (event) {
    return Modal.dispatch(target, event);
  };
};

module.exports = Modal;
示例#4
0
 it('should create new callbacks list if not existing', function () {
   var eventSystem = SimpleEventSystem();
   eventSystem.register('target', 'callback');
   eventSystem.getCallbacks()['target'].should.be.eql(['callback']);
 });
示例#5
0
    it('should remove callback from the list', function () {
      var eventSystem = SimpleEventSystem();
      eventSystem.unregister('target');

      eventSystem.getCallbacks()['target'].should.be.eql([]);
    });