"use strict";

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

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

var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));

var _chai = require("chai");

var _notification = _interopRequireDefault(require("../../notification"));

var _iconSettings = _interopRequireDefault(require("../../icon-settings"));

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

/* eslint-disable react/no-render-return-value */

/* eslint-disable react/no-find-dom-node */
describe('SLDSNotification: ', function () {
  var generateNotification = function generateNotification(notificationInstance) {
    var reactCmp = _testUtils.default.renderIntoDocument(_react.default.createElement(_iconSettings.default, {
      iconPath: "/assets/icons"
    }, notificationInstance));

    return _reactDom.default.findDOMNode(reactCmp);
  };

  describe('component renders', function () {
    it('notification renders', function () {
      var notification = generateNotification(_react.default.createElement(_notification.default, {
        variant: "toast",
        theme: "success",
        isOpen: true,
        content: "hi"
      }));
      (0, _chai.expect)(notification).to.not.equal(undefined);
    });
  });
  describe('component basic props render', function () {
    it('renders variant', function () {
      var notification = generateNotification(_react.default.createElement(_notification.default, {
        variant: "toast",
        theme: "success",
        icon: "notification",
        isOpen: true,
        texture: true,
        animated: true,
        content: "hi"
      }));
      var alert = notification.getElementsByTagName('div')[0];
      (0, _chai.expect)(alert.className).to.include('slds-notify_toast');
    });
    it('renders theme', function () {
      var notification = generateNotification(_react.default.createElement(_notification.default, {
        variant: "toast",
        theme: "error",
        isOpen: true,
        content: "hi"
      }));
      var alert = notification.getElementsByTagName('div')[0];
      (0, _chai.expect)(alert.className).to.include('slds-theme_error');
    });
    it('renders icon', function () {
      var notification = generateNotification(_react.default.createElement(_notification.default, {
        variant: "alert",
        theme: "success",
        iconName: "notification",
        isOpen: true,
        texture: true,
        content: "hi"
      }));
      var close = notification.querySelectorAll('button');
      var svgs = notification.querySelectorAll('[*|href="/assets/icons/utility-sprite/svg/symbols.svg#notification"]');
      (0, _chai.expect)(close[0].className).to.include('slds-notify__close');
      (0, _chai.expect)(svgs[0]).to.exist;
    });
  });
  describe('dismiss notification click', function () {
    it('button onClick invokes method from props', function () {
      var onClick = sinon.spy();
      var notification = generateNotification(_react.default.createElement(_notification.default, {
        variant: "toast",
        theme: "success",
        iconName: "notification",
        onDismiss: onClick,
        isOpen: true,
        content: "hi"
      }));
      var dismissBtn = notification.getElementsByTagName('button')[0];

      _testUtils.default.Simulate.click(dismissBtn);

      (0, _chai.expect)(onClick.calledOnce).to.be.true;
    });
  });
});