"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _react = _interopRequireWildcard(require("react"));
var _storySettings = require("./storySettings");
var _MediaOverlay = _interopRequireDefault(require("../MediaOverlay"));
var _content = require("../docs/examples/content");
var _RTLWrapper = require("../../../stories/utils/RTLWrapper");
var _storybookSnapper = require("storybook-snapper");
var _visual = require("../../utils/test-utils/visual");
var _vanilla = require("@wix/wix-ui-test-utils/vanilla");
var _MediaOverlayUni = require("../MediaOverlay.uni.driver");
var _excluded = ["componentDidMount", "rtl", "done"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/MediaOverlay/test/MediaOverlay.visual.jsx",
  _this = void 0;
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var createDriver = function createDriver() {
  return (0, _vanilla.uniTestkitFactoryCreator)(_MediaOverlayUni.mediaOverlayDriverFactory)({
    wrapper: document.body,
    dataHook: _storySettings.storySettings.dataHook
  });
};
var hover = /*#__PURE__*/function () {
  var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(done) {
    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          _context.next = 2;
          return createDriver().hover();
        case 2:
          _context.next = 4;
          return (0, _visual.wait)(200);
        case 4:
          done();
        case 5:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return function hover(_x) {
    return _ref.apply(this, arguments);
  };
}();
var mediaUrl = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mM8Exv7FAAF8AJtZv8v8wAAAABJRU5ErkJggg==';
var commonProps = {
  media: mediaUrl
};
var tests = [{
  describe: 'media',
  its: [{
    it: 'Background Image'
  }, {
    it: 'Custom Node',
    props: {
      media: /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          height: '100%',
          background: 'linear-gradient(to right top, #051937, #004d7a, #008793, #00bf72, #a8eb12)'
        },
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 46,
          columnNumber: 13
        }
      })
    }
  }, {
    it: 'Without rounded borders',
    props: {
      media: /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          height: '100%',
          background: 'linear-gradient(to right top, #051937, #004d7a, #008793, #00bf72, #a8eb12)'
        },
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 60,
          columnNumber: 13
        }
      }),
      removeRoundedBorders: true
    }
  }, {
    it: 'With border radius',
    props: {
      media: /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          height: '100%',
          background: 'linear-gradient(to right top, #051937, #004d7a, #008793, #00bf72, #a8eb12)'
        },
        __self: void 0,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 75,
          columnNumber: 13
        }
      }),
      borderRadius: '12px 12px 0 0'
    }
  }]
}, {
  describe: 'skin',
  its: [{
    it: 'gradient',
    props: {
      skin: 'gradient'
    }
  }, {
    it: 'dark',
    props: {
      skin: 'dark'
    }
  }]
}, {
  describe: 'both skin and hoverSkin defined',
  its: [{
    it: 'both gradient without hover',
    props: {
      skin: 'gradient',
      hoverSkin: 'gradient'
    }
  }, {
    it: 'both gradient with hover',
    props: {
      skin: 'gradient',
      hoverSkin: 'gradient'
    },
    componentDidMount: hover
  }]
}, {
  describe: 'Content',
  its: [{
    it: 'all placements',
    props: {
      skin: 'gradient',
      children: _content.allPlacements
    }
  }, {
    it: 'bottom default and middle always',
    props: {
      skin: 'gradient',
      children: _content.topHoverMiddleAlwaysBottomDefault
    }
  }, {
    it: 'rtl',
    props: {
      skin: 'gradient',
      children: _content.numberedPlacements
    },
    rtl: true
  }]
}, {
  describe: 'Video',
  its: [{
    it: 'with play button',
    props: {
      isVideo: true,
      videoSrc: '',
      hoverSkin: 'dark',
      showPlayButton: true
    }
  }]
}];
var MediaOverlayWrapper = function MediaOverlayWrapper(_ref2) {
  var componentDidMount = _ref2.componentDidMount,
    rtl = _ref2.rtl,
    done = _ref2.done,
    props = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
  (0, _react.useEffect)(function () {
    return componentDidMount();
  }, [componentDidMount]);
  return /*#__PURE__*/_react["default"].createElement(_RTLWrapper.RTLWrapper, {
    rtl: rtl,
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 172,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      width: 250,
      height: 150
    },
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 173,
      columnNumber: 7
    }
  }, /*#__PURE__*/_react["default"].createElement(_MediaOverlay["default"], (0, _extends2["default"])({}, props, {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 174,
      columnNumber: 9
    }
  }))));
};
(0, _storybookSnapper.visualize)('MediaOverlay', function () {
  tests.forEach(function (_ref3) {
    var describe = _ref3.describe,
      its = _ref3.its;
    its.forEach(function (_ref4) {
      var it = _ref4.it,
        props = _ref4.props,
        _componentDidMount = _ref4.componentDidMount,
        rtl = _ref4.rtl;
      (0, _storybookSnapper.story)(describe, function () {
        (0, _storybookSnapper.snap)(it, function (done) {
          return /*#__PURE__*/_react["default"].createElement(MediaOverlayWrapper, (0, _extends2["default"])({}, commonProps, props, {
            dataHook: _storySettings.storySettings.dataHook,
            componentDidMount: function componentDidMount() {
              _componentDidMount && _componentDidMount(done);
            },
            rtl: rtl,
            __self: _this,
            __source: {
              fileName: _jsxFileName,
              lineNumber: 185,
              columnNumber: 11
            }
          }));
        });
      });
    });
  });
});