"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@storybook/react");
var _storybookSnapper = require("storybook-snapper");
var _Stepper = _interopRequireDefault(require("../Stepper"));
var _constants = require("../constants");
var _vanilla = require("@wix/wix-ui-test-utils/vanilla");
var _StepperUni = require("../Stepper.uni.driver");
var _storySettings = require("./storySettings");
var _excluded = ["componentDidMount", "done"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Stepper/test/Stepper.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 dataHook = _storySettings.storySettings.dataHook,
  storyName = _storySettings.storySettings.storyName;
var onClick = function onClick() {};
var stepperTestkitFactory = (0, _vanilla.uniTestkitFactoryCreator)(_StepperUni.stepperDriverFactory);
var createDriver = function createDriver() {
  return stepperTestkitFactory({
    wrapper: document.body,
    dataHook: dataHook
  });
};
var hoverFirstStep = /*#__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().hoverStep(0);
        case 2:
          done();
        case 3:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return function hoverFirstStep(_x) {
    return _ref.apply(this, arguments);
  };
}();
var getTestNameByType = function getTestNameByType(type, name) {
  return "type=".concat(type, "/").concat(name);
};
var generateStepTypeTests = function generateStepTypeTests(type) {
  return {
    describe: getTestNameByType(type, 'step types'),
    its: [{
      it: 'disabled',
      props: {
        type: type,
        steps: [{
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Disabled
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Disabled
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Disabled
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Disabled
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Disabled
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Disabled
        }],
        activeStep: 0
      }
    }, {
      it: 'completed',
      props: {
        type: type,
        steps: [{
          text: 'This is a long step name',
          type: _constants.StepType.Completed
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Completed
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Completed
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Completed
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Completed
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Completed
        }, {
          text: 'This is a long step name'
        }],
        activeStep: 6
      }
    }, {
      it: 'error',
      props: {
        type: type,
        steps: [{
          text: 'This is a long step name',
          type: _constants.StepType.Error
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Error
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Error
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Error
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Error
        }, {
          text: 'This is a long step name',
          type: _constants.StepType.Error
        }, {
          text: 'This is a long step name'
        }],
        activeStep: 6
      }
    }, {
      it: 'error & active',
      props: {
        type: type,
        steps: [{
          text: 'This is a long step name',
          type: _constants.StepType.Error
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }],
        activeStep: 0
      }
    }, {
      it: 'completed & active',
      props: {
        type: type,
        steps: [{
          text: 'This is a long step name',
          type: _constants.StepType.Completed
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }, {
          text: 'This is a long step name'
        }],
        activeStep: 0
      }
    }]
  };
};
var generateHoverTests = function generateHoverTests(type) {
  return {
    describe: getTestNameByType(type, 'hover'),
    its: [{
      it: 'disabled',
      props: {
        type: type,
        steps: [{
          text: 'step1',
          type: _constants.StepType.Disabled
        }, {
          text: 'step2'
        }, {
          text: 'step3'
        }],
        activeStep: 1,
        onClick: onClick
      },
      componentDidMount: hoverFirstStep
    }, {
      it: 'active',
      props: {
        type: type,
        steps: [{
          text: 'step1'
        }, {
          text: 'step2'
        }, {
          text: 'step3'
        }],
        activeStep: 0,
        onClick: onClick
      },
      componentDidMount: hoverFirstStep
    }, {
      it: 'error & active',
      props: {
        type: type,
        steps: [{
          text: 'step1',
          type: _constants.StepType.Error
        }, {
          text: 'step2'
        }, {
          text: 'step3'
        }],
        activeStep: 0,
        onClick: onClick
      },
      componentDidMount: hoverFirstStep
    }, {
      it: 'completed & active',
      props: {
        type: type,
        steps: [{
          text: 'step1',
          type: _constants.StepType.Completed
        }, {
          text: 'step2'
        }, {
          text: 'step3'
        }],
        activeStep: 0,
        onClick: onClick
      },
      componentDidMount: hoverFirstStep
    }]
  };
};
var generateResponsiveTests = function generateResponsiveTests(type) {
  return {
    describe: getTestNameByType(type, 'responsive'),
    its: [{
      it: '4 steps',
      props: {
        type: type,
        steps: [{
          text: 'First step'
        }, {
          text: 'Second step'
        }, {
          text: 'Third step'
        }, {
          text: 'Forth step'
        }],
        activeStep: 1
      }
    }, {
      it: '7 steps',
      props: {
        type: type,
        steps: [{
          text: 'First step'
        }, {
          text: 'Second step'
        }, {
          text: 'Third step'
        }, {
          text: 'Forth step'
        }, {
          text: 'Fifth step'
        }, {
          text: 'Six step'
        }, {
          text: 'Seventh step'
        }],
        activeStep: 1
      }
    }]
  };
};
var generateFitModeTests = function generateFitModeTests(type) {
  return {
    describe: getTestNameByType(type, 'fit'),
    its: [{
      it: 'stretched',
      props: {
        type: type,
        fit: _constants.FitMode.Stretched,
        steps: [{
          text: 'First step'
        }, {
          text: 'Second step'
        }, {
          text: 'Third step'
        }, {
          text: 'Forth step'
        }],
        activeStep: 0
      }
    }]
  };
};
var tests = [generateStepTypeTests(_constants.Type.Circle), generateStepTypeTests(_constants.Type.Text), generateResponsiveTests(_constants.Type.Circle), generateResponsiveTests(_constants.Type.Text), generateFitModeTests(_constants.Type.Circle), generateFitModeTests(_constants.Type.Text)];
var interactiveTests = [generateHoverTests(_constants.Type.Circle), generateHoverTests(_constants.Type.Text)];
tests.forEach(function (_ref2) {
  var describe = _ref2.describe,
    its = _ref2.its;
  its.forEach(function (_ref3) {
    var it = _ref3.it,
      props = _ref3.props;
    (0, _react2.storiesOf)("".concat(storyName).concat(describe ? '/' + describe : ''), module).add(it, function () {
      return /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          padding: 20,
          width: 966,
          border: '1px solid black'
        },
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 245,
          columnNumber: 9
        }
      }, /*#__PURE__*/_react["default"].createElement(_Stepper["default"], (0, _extends2["default"])({}, props, {
        __self: _this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 252,
          columnNumber: 11
        }
      })));
    });
  });
});
var InteractiveStepperWrapper = function InteractiveStepperWrapper(_ref4) {
  var componentDidMount = _ref4.componentDidMount,
    done = _ref4.done,
    props = (0, _objectWithoutProperties2["default"])(_ref4, _excluded);
  (0, _react.useEffect)(function () {
    componentDidMount && componentDidMount(done);
  }, [componentDidMount, done]);
  return /*#__PURE__*/_react["default"].createElement(_Stepper["default"], (0, _extends2["default"])({}, props, {
    __self: _this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 264,
      columnNumber: 10
    }
  }));
};
interactiveTests.forEach(function (_ref5) {
  var describe = _ref5.describe,
    its = _ref5.its;
  its.forEach(function (_ref6) {
    var it = _ref6.it,
      props = _ref6.props,
      componentDidMount = _ref6.componentDidMount;
    (0, _storybookSnapper.visualize)("".concat(storyName, "/").concat(describe), function () {
      (0, _storybookSnapper.snap)(it, function (done) {
        return /*#__PURE__*/_react["default"].createElement(InteractiveStepperWrapper, (0, _extends2["default"])({
          dataHook: dataHook
        }, props, {
          componentDidMount: componentDidMount,
          done: done,
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 271,
            columnNumber: 9
          }
        }));
      });
    });
  });
});