"use strict";

var _constants = require("@instructure/quiz-common/lib/constants");

var _alerts = require("../alerts");

describe('alert action creators', function () {
  var actionWellFormed = function actionWellFormed(actionCreator, variant) {
    var removeIn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _constants.DEFAULT_ALERT_TIME;
    var message = 'this is the message to show';
    var errorAction = actionCreator(message);
    expect(errorAction.type, 'bad type').to.be.equal(_constants.ADD_ALERT);
    expect(errorAction.payload.message, 'bad payload message').to.be.equal(message);
    expect(errorAction.payload.variant, 'bad payload variant').to.be.equal(variant);
    expect(errorAction.payload.removeIn, 'bad payload removeIn').to.be.equal(removeIn);
    expect(errorAction.payload.uuid, 'bad uuid').to.not.be.undefined();
  };

  it('returns a well-formed add error action', function () {
    actionWellFormed(_alerts.addError, 'error');
  });
  it('returns a well-formed add success action', function () {
    actionWellFormed(_alerts.addSuccess, 'success');
  });
  it('returns a well-formed add info action', function () {
    actionWellFormed(_alerts.addInfo, 'info');
  });
  it('returns a well-formed screenreader action', function () {
    actionWellFormed(_alerts.screenreaderNotification, 'screenreader', 2000);
  });
  it('returns a well-formed remove alert action', function () {
    var errorID = '12345';
    var removeAlertAction = (0, _alerts.removeAlert)(errorID);
    expect(removeAlertAction).to.deep.equal({
      type: _constants.REMOVE_ALERT,
      payload: {
        uuid: errorID
      }
    });
  });
});