import { jsx as ___EmotionJSX } from "@emotion/core";

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

import React from 'react';
import renderer from 'react-test-renderer';
import { shallow } from 'enzyme';
import Alert from './index';
var testAlert = {
  text: 'Your email address was updated successfully!',
  type: 'success',
  duration: 'sticky'
};
describe('Alert UI snapshots', function () {
  test('renders success type and text', function () {
    var component = renderer.create(___EmotionJSX(Alert, {
      text: testAlert.text,
      type: "success",
      duration: testAlert.duration,
      onExit: function onExit() {}
    }));
    var tree = component.toJSON();
    expect(tree).toMatchSnapshot();
  });
  test('renders danger type and text', function () {
    var component = renderer.create(___EmotionJSX(Alert, {
      text: testAlert.text,
      type: "danger",
      duration: testAlert.duration,
      onExit: function onExit() {}
    }));
    var tree = component.toJSON();
    expect(tree).toMatchSnapshot();
  });
  test('renders info type and text', function () {
    var component = renderer.create(___EmotionJSX(Alert, {
      text: testAlert.text,
      type: "info",
      duration: testAlert.duration,
      onExit: function onExit() {}
    }));
    var tree = component.toJSON();
    expect(tree).toMatchSnapshot();
  });
});
test('Alert onExit is triggered on click', function () {
  jest.useFakeTimers();
  var spy = jest.fn();
  var alert = shallow(___EmotionJSX(Alert, _extends({
    onExit: spy
  }, testAlert)));
  alert.simulate('click');
  jest.runAllTimers();
  expect(spy).toHaveBeenCalled();
});