Beispiel #1
0
describe('OverlayStore', function () {
  var callback = AppDispatcher.getCallback(OverlayStore.dispatcherToken);

  var toggleOverlay = function () {
    callback({
      actionType: AppConstants.TOGGLE_OVERLAY
    });
  };

  beforeEach(function () {
    callback({ actionType: AppConstants.CLOSE_SHARE_BAR });
  });

  it('should toggle when actions said so', function () {
    toggleOverlay();
    OverlayStore.getState().active.should.be.true();
    toggleOverlay();
    OverlayStore.getState().active.should.be.false();
  });

  it('should deactive when share bar close', function () {
    toggleOverlay();
    callback({
      actionType: AppConstants.CLOSE_SHARE_BAR
    });
    OverlayStore.getState().active.should.be.false();
  });

  it('should active when share bar open', function () {
    callback({
      actionType: AppConstants.RECEIVED_SHARED_SESSION
    });
    OverlayStore.getState().active.should.be.true();
  });
});
Beispiel #2
0
describe('ShareButtonStore', function () {
  var callback = AppDispatcher.getCallback(ShareButtonStore.dispatcherIndex);

  it('becomes inactive when close share bar', function () {
    ShareButtonStore.updateState('active', true);
    callback({
      actionType: AppConstants.CLOSE_SHARE_BAR
    });
    (ShareButtonStore.isActive()).should.not.be.true();
  });

  it('updates shared url when receive shared session', function () {
    sinon.stub(locationUtils, 'getWindowHref').returns('host/data/xyz567/slug');
    callback({actionType: AppConstants.RECEIVED_SHARED_SESSION, data: {data: {hash: 'abcd12'}}});
    (ShareButtonStore.getState()['sharedSessionHashId']).should.be.equal('abcd12');
    (ShareButtonStore.getState()['sharedUrl']).should.be.equal('host/data/abcd12/slug');
    locationUtils.getWindowHref.restore();
  });

  it('updates shared url when site title change', function () {
    sinon.stub(locationUtils, 'getWindowHref').returns('host/data/xyz567/slug');
    ShareButtonStore.updateState('sharedSessionHashId', 'wxy234');
    callback({actionType: AppConstants.CHANGE_SITE_TITLE, title: 'Police database'});
    (ShareButtonStore.getState()['sharedUrl']).should.be.equal('host/data/wxy234/police-database');
    locationUtils.getWindowHref.restore();
  });
});
Beispiel #3
0
describe('InterfaceTextStore', function () {
  var callback = AppDispatcher.getCallback(InterfaceTextStore.dispatcherToken);

  it('should update loaded to true if data is already loaded', function () {
    InterfaceTextStore.updateState('loaded', false);

    callback({
      actionType: AppConstants.GET_INTERFACE_TEXT_SUCCESS
    });

    InterfaceTextStore.getState().loaded.should.be.true();
  });

  it('should update loaded to false if data is not loaded yet', function () {
    InterfaceTextStore.updateState('loaded', true);

    callback({
      actionType: AppConstants.GET_INTERFACE_TEXT_FAILED
    });

    InterfaceTextStore.getState().loaded.should.be.false();
  });
});