import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["componentDidMount"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/esm/ColorPicker/test/ColorPicker.visual.jsx",
  _this = this;
import _regeneratorRuntime from "@babel/runtime/regenerator";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import React, { useEffect } from 'react';
import ColorPicker from '../index';
import { snap, visualize } from 'storybook-snapper';
import { clickElement, focusElement } from '../../utils/test-utils/visual';
import { DataHooks } from '../constants';
var dataHook = 'interactive';
var clickConverter = function clickConverter(converter) {
  var dataHookSelector = '';
  switch (converter) {
    case 'hex':
      dataHookSelector = DataHooks.hexConverterBtn;
      break;
    case 'rgb':
      dataHookSelector = DataHooks.rgbConverterBtn;
      break;
    case 'hsb':
      dataHookSelector = DataHooks.hsbConverterBtn;
      break;
  }
  clickElement(dataHookSelector);
  focusElement(dataHookSelector);
};
var ColorPickerWrapper = function ColorPickerWrapper(_ref) {
  var componentDidMount = _ref.componentDidMount,
    rest = _objectWithoutProperties(_ref, _excluded);
  useEffect(function () {
    componentDidMount && componentDidMount();
  }, [componentDidMount]);
  return /*#__PURE__*/React.createElement(ColorPicker, _extends({
    dataHook: dataHook
  }, rest, {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 31,
      columnNumber: 10
    }
  }));
};
var defaultProps = {
  value: '#3899eb',
  emptyPlaceholder: 'No Fill'
};
// showConverter={false} showInput={false}
var tests = [{
  describe: 'ColorPicker',
  its: [{
    it: 'should render with input and converter',
    props: _objectSpread({}, defaultProps)
  }, {
    it: 'should render with input and  without converter',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showConverter: false
    })
  }, {
    it: 'should render without input and converter',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showInput: false,
      showConverter: false
    })
  }, {
    it: 'should render without action buttons',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showActionButtons: false
    })
  }, {
    it: 'should render the RGB inputs when clicking on the RGB tab',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showConverter: true
    }),
    componentDidMount: function componentDidMount() {
      return clickConverter('rgb');
    }
  }, {
    it: 'should render the HSB inputs when clicking on the HSB tab',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      showConverter: true
    }),
    componentDidMount: function () {
      var _componentDidMount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
        return _regeneratorRuntime.wrap(function _callee$(_context) {
          while (1) switch (_context.prev = _context.next) {
            case 0:
              return _context.abrupt("return", clickConverter('hsb'));
            case 1:
            case "end":
              return _context.stop();
          }
        }, _callee);
      }));
      function componentDidMount() {
        return _componentDidMount.apply(this, arguments);
      }
      return componentDidMount;
    }()
  }, {
    it: 'should render with padding (default)',
    props: _objectSpread({}, defaultProps)
  }, {
    it: 'should render without padding',
    props: _objectSpread(_objectSpread({}, defaultProps), {}, {
      removePadding: true
    })
  }]
}];
tests.forEach(function (_ref2) {
  var describe = _ref2.describe,
    its = _ref2.its;
  its.forEach(function (_ref3) {
    var it = _ref3.it,
      props = _ref3.props,
      componentDidMount = _ref3.componentDidMount;
    visualize(describe, function () {
      snap(it, function (done) {
        return /*#__PURE__*/React.createElement(ColorPickerWrapper, _extends({}, props, {
          componentDidMount: componentDidMount,
          onDone: done,
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 106,
            columnNumber: 9
          }
        }));
      });
    });
  });
});