"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _uuid = require("uuid");

var _immutable = require("immutable");

var _reactDom = _interopRequireDefault(require("react-dom"));

var _Alert = _interopRequireDefault(require("@instructure/ui-alerts/lib/components/Alert"));

var _ScreenReaderContent = _interopRequireDefault(require("@instructure/ui-a11y/lib/components/ScreenReaderContent"));

var _presenter = _interopRequireDefault(require("../presenter"));

var _Alert2 = _interopRequireDefault(require("../../../records/Alert"));

describe('Alerts', function () {
  var firstId = (0, _uuid.v4)();
  var secondId = (0, _uuid.v4)();
  var removeAlertStub = sinon.stub();
  var testbed = createTestbed(_presenter.default, {
    alerts: (0, _immutable.List)([new _Alert2.default({
      message: 'hey',
      uuid: firstId
    }), new _Alert2.default({
      message: 'hola',
      uuid: secondId
    })]),
    sidebarOpen: false,
    removeAlert: removeAlertStub
  });
  shouldRenderComponent(testbed, {}, _presenter.default);
  afterEach(function () {
    removeAlertStub.resetHistory();
  });
  it('should render given alerts', function () {
    testbed.render();
    var renderedAlerts = testbed.findChildrenByType(_Alert.default);
    expect(renderedAlerts.length).to.be.equal(2);
  });
  it('should render screenreader alerts', function () {
    testbed.render({
      alerts: (0, _immutable.List)([new _Alert2.default({
        message: 'sr only',
        uuid: '1',
        variant: 'screenreader'
      })])
    });
    var srContent = testbed.findChildrenByType(_ScreenReaderContent.default)[0];

    var srNode = _reactDom.default.findDOMNode(srContent);

    expect(srNode.innerText).to.include('sr only');
  });
  it('should call the removeAlert action when alert is dismissed', function () {
    testbed.render();
    var alert = testbed.findChildrenByType(_Alert.default)[0];
    alert.props.onDismiss();
    expect(removeAlertStub).to.have.been.called();
  });
  describe('a11y tests', function () {
    it('should meet a11y standards', function (done) {
      testbed.render();
      testbed.checkA11yStandards(done);
    });
  });
});