"use strict";

var _react = _interopRequireDefault(require("react"));

var _index = require("../index");

var _build = _interopRequireWildcard(require("enzyme/build"));

var _build2 = _interopRequireDefault(require("enzyme-adapter-react-16/build"));

var _IconSuccess = _interopRequireDefault(require("../../IconSuccess"));

var _IconInfo = _interopRequireDefault(require("../../IconInfo"));

var _IconWarning = _interopRequireDefault(require("../../IconWarning"));

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

_build.default.configure({
  adapter: new _build2.default()
});

describe('Alert', function () {
  it('should render', function () {
    var onClose = function onClose() {};

    var wrapper = (0, _build.shallow)(_react.default.createElement(_index.Alert, {
      type: "info",
      closeType: "icon",
      onClose: onClose
    }, "You have completed the form."));
    var alert = wrapper.find('.vs-info-alert');
    expect(alert).toHaveLength(1);
    expect(alert.contains(_react.default.createElement("div", {
      className: "vs-alert-content"
    }, "You have completed the form."))).toEqual(true);
  });
  it('should render an info icon when the info type is passed in', function () {
    var onClose = function onClose() {};

    var wrapper = (0, _build.shallow)(_react.default.createElement(_index.Alert, {
      type: "info",
      closeType: "icon",
      onClose: onClose
    }, "You have completed the form."));
    var alert = wrapper.find('.vs-info-alert');
    expect(alert.contains(_react.default.createElement(_IconInfo.default, {
      className: "vs-alert-icon"
    }))).toEqual(true);
    wrapper.unmount();
  });
  it('should render a success icon when the success type is passed in', function () {
    var onClose = function onClose() {};

    var wrapper = (0, _build.shallow)(_react.default.createElement(_index.Alert, {
      type: "success",
      closeType: "icon",
      onClose: onClose
    }, "You have completed the form."));
    var alert = wrapper.find('.vs-success-alert');
    expect(alert.contains(_react.default.createElement(_IconSuccess.default, {
      className: "vs-alert-icon"
    }))).toEqual(true);
    wrapper.unmount();
  });
  it('should render a warning icon when the warning type is passed in', function () {
    var onClose = function onClose() {};

    var wrapper = (0, _build.shallow)(_react.default.createElement(_index.Alert, {
      type: "warning",
      closeType: "icon",
      onClose: onClose
    }, "You have completed the form."));
    var alert = wrapper.find('.vs-warning-alert');
    expect(alert.contains(_react.default.createElement(_IconWarning.default, {
      className: "vs-alert-icon"
    }))).toEqual(true);
    wrapper.unmount();
  });
  it('should render a close icon when the icon closeType is passed in', function () {
    var onClose = function onClose() {};

    var wrapper = (0, _build.shallow)(_react.default.createElement(_index.Alert, {
      type: "info",
      closeType: "icon",
      onClose: onClose
    }, "You have completed the form."));
    var alert = wrapper.find('.vs-info-alert');
    expect(alert.debug().indexOf('<CloseIcon className="vs-alert-close-icon" onClick={[Function: onClick]} />') > -1).toEqual(true);
    wrapper.unmount();
  });
  it('should render a close button when the button closeType is passed in', function () {
    var onClose = function onClose() {};

    var wrapper = (0, _build.shallow)(_react.default.createElement(_index.Alert, {
      type: "info",
      closeType: "button",
      onClose: onClose
    }, "You have completed the form."));
    var alert = wrapper.find('.vs-info-alert');
    expect(alert.debug().indexOf('<Component type="outline-secondary" className="vs-alert-close-button" onClick={[Function: onClick]} />') > -1).toEqual(true);
    wrapper.unmount();
  });
});