"use strict";

var _jsxRuntime = require("react/jsx-runtime");

var _enzyme = require("enzyme");

var _Popup = require("../Popup");

var _PopupModule = _interopRequireDefault(require("../Popup.module.css"));

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

describe('Popup specs', function () {
  test('should set role to alert by default', function () {
    var popup = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        children: "popup"
      })
    }));
    var expected = 'alert';
    var actual = popup.find(".".concat(_PopupModule["default"].popup)).prop('role');
    expect(actual).toBe(expected);
  });
  test('should be rendered opened if open is set to true', function () {
    var popup = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.Popup, {
      open: true,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        children: "popup"
      })
    }));
    var expected = true;
    var actual = popup.prop('open');
    expect(actual).toBe(expected);
  });
  test('should not be rendered if open is set to false', function () {
    var popup = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.Popup, {
      open: false,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        children: "popup"
      })
    }));
    var expected = false;
    var actual = popup.prop('open');
    expect(actual).toBe(expected);
  });
  describe('with centered content', function () {
    test('should be rendered with centered content if centered is set to true', function () {
      var popup = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.Popup, {
        centered: true
      }));
      var expected = true;
      var actual = popup.prop('centered');
      expect(actual).toBe(expected);
    });
    test('should not be rendered with centered content if centered is set to false', function () {
      var popup = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.Popup, {
        centered: false
      }));
      var expected = false;
      var actual = popup.prop('centered');
      expect(actual).toBe(expected);
    });
  });
  describe('with position center', function () {
    test('should have position=center when no position is specified', function () {
      var popup = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {}));
      var expected = 'center';
      var actual = popup.prop('position');
      expect(actual).toBe(expected);
    });
  });
  describe('with position top', function () {
    test('should have top class', function () {
      var popup = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {
        open: true,
        position: "top",
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          children: "popup"
        })
      }));
      expect(popup.find(".".concat(_PopupModule["default"].popup)).prop('className').split(' ')).toContain('top');
    });
  });
  describe('with position changes dynamically', function () {
    test('should not have top class when position change from top to any other position', function () {
      var firstPosition = 'top';
      var popup = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {
        open: true,
        position: firstPosition,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          children: "popup"
        })
      }));
      expect(popup.find(".".concat(_PopupModule["default"].popup)).prop('className').split(' ')).toContain(firstPosition);
      expect(popup.find(".".concat(_PopupModule["default"].popup)).prop('className').split(' ')).not.toContain('center');
      expect(popup.prop('className').split(' ')).not.toContain('center');
      popup.setProps({
        position: 'center'
      });
      expect(popup.find(".".concat(_PopupModule["default"].popup)).prop('className').split(' ')).not.toContain(firstPosition);
      expect(popup.prop('className').split(' ')).not.toContain(firstPosition);
    });
  });
  test('should have `center` class when position prop is set to `center` (default)', function () {
    var popup = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {
      position: "center"
    }));
    var expected = 'center';
    var actual = popup.find(".".concat(_PopupModule["default"].popup)).prop('className');
    expect(actual).toContain(expected);
  });
  test('should have `top` class when position prop is set to `top`', function () {
    var popup = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {
      position: "top"
    }));
    var expected = 'top';
    var actual = popup.find(".".concat(_PopupModule["default"].popup)).prop('className');
    expect(actual).toContain(expected);
  });
  test('should have `bottom` class when position prop is set to `bottom`', function () {
    var popup = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {
      position: "bottom"
    }));
    var expected = 'bottom';
    var actual = popup.find(".".concat(_PopupModule["default"].popup)).prop('className');
    expect(actual).toContain(expected);
  });
  test('should have `left` class when position prop is set to `left`', function () {
    var popup = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {
      position: "left"
    }));
    var expected = 'left';
    var actual = popup.find(".".concat(_PopupModule["default"].popup)).prop('className');
    expect(actual).toContain(expected);
  });
  test('should have `right` class when position prop is set to `right`', function () {
    var popup = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {
      position: "right"
    }));
    var expected = 'right';
    var actual = popup.find(".".concat(_PopupModule["default"].popup)).prop('className');
    expect(actual).toContain(expected);
  });
  test('should have `fullscreen` class when position prop is set to `fullscreen`', function () {
    var popup = (0, _enzyme.shallow)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popup.PopupBase, {
      position: "fullscreen"
    }));
    var expected = 'fullscreen';
    var actual = popup.find(".".concat(_PopupModule["default"].popup)).prop('className');
    expect(actual).toContain(expected);
  });
});