"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _react = _interopRequireDefault(require("react"));
var _react2 = require("../../utils/test-utils/react");
var _Stepper = _interopRequireDefault(require("../Stepper"));
var _constants = require("../constants");
var _StepperPrivateUni = require("./Stepper.private.uni.driver");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Stepper/test/Stepper.spec.jsx",
  _this = void 0;
var steps7 = [{
  text: 'step 1'
}, {
  text: 'step 2'
}, {
  text: 'step 3'
}, {
  text: 'step 4'
}, {
  text: 'step 5'
}, {
  text: 'step 6'
}, {
  text: 'step 7'
}];
var render = (0, _react2.createRendererWithUniDriver)(_StepperPrivateUni.stepperPrivateDriverFactory);
describe('Stepper', function () {
  describe('Click', function () {
    var onClick;
    beforeEach(function () {
      onClick = vi.fn();
    });
    it('should not trigger for an active step', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
      var steps, _render, driver;
      return _regenerator["default"].wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            steps = [{
              text: 'step'
            }, {
              text: 'step'
            }];
            _render = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              onClick: onClick,
              steps: steps,
              activeStep: 0,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 30,
                columnNumber: 9
              }
            })), driver = _render.driver;
            _context.next = 4;
            return driver.clickStep(0);
          case 4:
            expect(onClick).not.toHaveBeenCalled();
          case 5:
          case "end":
            return _context.stop();
        }
      }, _callee);
    })));
    it('should not trigger for a disabled step', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
      var steps, _render2, driver;
      return _regenerator["default"].wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            steps = [{
              text: 'active step'
            }, {
              text: 'disabled step',
              type: _constants.StepType.Disabled
            }];
            _render2 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              onClick: onClick,
              steps: steps,
              activeStep: 0,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 43,
                columnNumber: 9
              }
            })), driver = _render2.driver;
            _context2.next = 4;
            return driver.clickStep(1);
          case 4:
            expect(onClick).not.toHaveBeenCalled();
          case 5:
          case "end":
            return _context2.stop();
        }
      }, _callee2);
    })));
    it('should trigger for a completed step', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
      var steps, _render3, driver;
      return _regenerator["default"].wrap(function _callee3$(_context3) {
        while (1) switch (_context3.prev = _context3.next) {
          case 0:
            steps = [{
              text: 'step',
              type: _constants.StepType.Completed
            }, {
              text: 'step'
            }];
            _render3 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              onClick: onClick,
              steps: steps,
              activeStep: 1,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 56,
                columnNumber: 9
              }
            })), driver = _render3.driver;
            _context3.next = 4;
            return driver.clickStep(0);
          case 4:
            expect(onClick).toHaveBeenCalledTimes(1);
          case 5:
          case "end":
            return _context3.stop();
        }
      }, _callee3);
    })));
    it('should trigger for a normal step', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
      var steps, _render4, driver;
      return _regenerator["default"].wrap(function _callee4$(_context4) {
        while (1) switch (_context4.prev = _context4.next) {
          case 0:
            steps = [{
              text: 'step'
            }, {
              text: 'step'
            }];
            _render4 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              onClick: onClick,
              steps: steps,
              activeStep: 0,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 66,
                columnNumber: 9
              }
            })), driver = _render4.driver;
            _context4.next = 4;
            return driver.clickStep(1);
          case 4:
            expect(onClick).toHaveBeenCalledTimes(1);
          case 5:
          case "end":
            return _context4.stop();
        }
      }, _callee4);
    })));
    it('should trigger for an error step', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5() {
      var steps, _render5, driver;
      return _regenerator["default"].wrap(function _callee5$(_context5) {
        while (1) switch (_context5.prev = _context5.next) {
          case 0:
            steps = [{
              text: 'step'
            }, {
              text: 'step',
              type: _constants.StepType.Error
            }];
            _render5 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              onClick: onClick,
              steps: steps,
              activeStep: 0,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 76,
                columnNumber: 9
              }
            })), driver = _render5.driver;
            _context5.next = 4;
            return driver.clickStep(1);
          case 4:
            expect(onClick).toHaveBeenCalledTimes(1);
          case 5:
          case "end":
            return _context5.stop();
        }
      }, _callee5);
    })));
  });
  describe('Render', function () {
    it('should render all given steps', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee6() {
      var _render6, driver, i;
      return _regenerator["default"].wrap(function _callee6$(_context6) {
        while (1) switch (_context6.prev = _context6.next) {
          case 0:
            _render6 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              steps: steps7,
              activeStep: 1,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 86,
                columnNumber: 33
              }
            })), driver = _render6.driver;
            _context6.t0 = expect;
            _context6.next = 4;
            return driver.getNumberOfSteps();
          case 4:
            _context6.t1 = _context6.sent;
            (0, _context6.t0)(_context6.t1).toBe(steps7.length);
            i = 0;
          case 7:
            if (!(i < steps7.length)) {
              _context6.next = 16;
              break;
            }
            _context6.t2 = expect;
            _context6.next = 11;
            return driver.getStepText(i);
          case 11:
            _context6.t3 = _context6.sent;
            (0, _context6.t2)(_context6.t3).toBe("step ".concat(i + 1));
          case 13:
            i++;
            _context6.next = 7;
            break;
          case 16:
          case "end":
            return _context6.stop();
        }
      }, _callee6);
    })));
    it('should render exactly one active step', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7() {
      var _render7, driver, i;
      return _regenerator["default"].wrap(function _callee7$(_context7) {
        while (1) switch (_context7.prev = _context7.next) {
          case 0:
            _render7 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              steps: steps7,
              activeStep: 1,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 95,
                columnNumber: 33
              }
            })), driver = _render7.driver;
            i = 0;
          case 2:
            if (!(i < steps7.length)) {
              _context7.next = 19;
              break;
            }
            if (!(i === 1)) {
              _context7.next = 11;
              break;
            }
            _context7.t0 = expect;
            _context7.next = 7;
            return driver.isStepActive(i);
          case 7:
            _context7.t1 = _context7.sent;
            (0, _context7.t0)(_context7.t1).toBe(true);
            _context7.next = 16;
            break;
          case 11:
            _context7.t2 = expect;
            _context7.next = 14;
            return driver.isStepActive(i);
          case 14:
            _context7.t3 = _context7.sent;
            (0, _context7.t2)(_context7.t3).toBe(false);
          case 16:
            i++;
            _context7.next = 2;
            break;
          case 19:
          case "end":
            return _context7.stop();
        }
      }, _callee7);
    })));
    it('should render normal, completed, error and disabled step types', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee8() {
      var allKindOfSteps, _render8, driver;
      return _regenerator["default"].wrap(function _callee8$(_context8) {
        while (1) switch (_context8.prev = _context8.next) {
          case 0:
            allKindOfSteps = [{
              text: 'normal step'
            }, {
              text: 'disabled step',
              type: _constants.StepType.Disabled
            }, {
              text: 'completed step',
              type: _constants.StepType.Completed
            }, {
              text: 'error step',
              type: _constants.StepType.Error
            }];
            _render8 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              steps: allKindOfSteps,
              activeStep: 0,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 114,
                columnNumber: 9
              }
            })), driver = _render8.driver;
            _context8.t0 = expect;
            _context8.next = 5;
            return driver.getStepType(0);
          case 5:
            _context8.t1 = _context8.sent;
            (0, _context8.t0)(_context8.t1).toBe(_constants.StepType.Normal);
            _context8.t2 = expect;
            _context8.next = 10;
            return driver.getStepType(1);
          case 10:
            _context8.t3 = _context8.sent;
            (0, _context8.t2)(_context8.t3).toBe(_constants.StepType.Disabled);
            _context8.t4 = expect;
            _context8.next = 15;
            return driver.getStepType(2);
          case 15:
            _context8.t5 = _context8.sent;
            (0, _context8.t4)(_context8.t5).toBe(_constants.StepType.Completed);
            _context8.t6 = expect;
            _context8.next = 20;
            return driver.getStepType(3);
          case 20:
            _context8.t7 = _context8.sent;
            (0, _context8.t6)(_context8.t7).toBe(_constants.StepType.Error);
          case 22:
          case "end":
            return _context8.stop();
        }
      }, _callee8);
    })));
  });
  describe('Style type', function () {
    it('should have "circle" type by default', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee9() {
      var _render9, driver;
      return _regenerator["default"].wrap(function _callee9$(_context9) {
        while (1) switch (_context9.prev = _context9.next) {
          case 0:
            _render9 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              steps: steps7,
              activeStep: 0,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 126,
                columnNumber: 33
              }
            })), driver = _render9.driver;
            _context9.t0 = expect;
            _context9.next = 4;
            return driver.getType();
          case 4:
            _context9.t1 = _context9.sent;
            (0, _context9.t0)(_context9.t1).toBe(_constants.Type.Circle);
          case 6:
          case "end":
            return _context9.stop();
        }
      }, _callee9);
    })));
    it('should render "text" type', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee0() {
      var _render0, driver;
      return _regenerator["default"].wrap(function _callee0$(_context0) {
        while (1) switch (_context0.prev = _context0.next) {
          case 0:
            _render0 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              steps: steps7,
              activeStep: 0,
              type: _constants.Type.Text,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 132,
                columnNumber: 9
              }
            })), driver = _render0.driver;
            _context0.t0 = expect;
            _context0.next = 4;
            return driver.getType();
          case 4:
            _context0.t1 = _context0.sent;
            (0, _context0.t0)(_context0.t1).toBe(_constants.Type.Text);
          case 6:
          case "end":
            return _context0.stop();
        }
      }, _callee0);
    })));
  });
  describe('Style size', function () {
    it('should have "small" size default', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee1() {
      var _render1, driver;
      return _regenerator["default"].wrap(function _callee1$(_context1) {
        while (1) switch (_context1.prev = _context1.next) {
          case 0:
            _render1 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              steps: steps7,
              activeStep: 0,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 140,
                columnNumber: 33
              }
            })), driver = _render1.driver;
            _context1.t0 = expect;
            _context1.next = 4;
            return driver.getSize();
          case 4:
            _context1.t1 = _context1.sent;
            (0, _context1.t0)(_context1.t1).toBe('small');
          case 6:
          case "end":
            return _context1.stop();
        }
      }, _callee1);
    })));
    it('should render "medium" size', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee10() {
      var _render10, driver;
      return _regenerator["default"].wrap(function _callee10$(_context10) {
        while (1) switch (_context10.prev = _context10.next) {
          case 0:
            _render10 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              steps: steps7,
              activeStep: 0,
              type: _constants.Type.Text,
              size: "medium",
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 146,
                columnNumber: 9
              }
            })), driver = _render10.driver;
            _context10.t0 = expect;
            _context10.next = 4;
            return driver.getSize();
          case 4:
            _context10.t1 = _context10.sent;
            (0, _context10.t0)(_context10.t1).toBe('medium');
          case 6:
          case "end":
            return _context10.stop();
        }
      }, _callee10);
    })));
  });
  describe('Fit mode', function () {
    it('should have "compact" mode by default', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee11() {
      var _render11, driver;
      return _regenerator["default"].wrap(function _callee11$(_context11) {
        while (1) switch (_context11.prev = _context11.next) {
          case 0:
            _render11 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              steps: steps7,
              activeStep: 0,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 159,
                columnNumber: 33
              }
            })), driver = _render11.driver;
            _context11.t0 = expect;
            _context11.next = 4;
            return driver.getFit();
          case 4:
            _context11.t1 = _context11.sent;
            (0, _context11.t0)(_context11.t1).toBe(_constants.FitMode.Compact);
          case 6:
          case "end":
            return _context11.stop();
        }
      }, _callee11);
    })));
    it('should render in "stretched" mode', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee12() {
      var _render12, driver;
      return _regenerator["default"].wrap(function _callee12$(_context12) {
        while (1) switch (_context12.prev = _context12.next) {
          case 0:
            _render12 = render(/*#__PURE__*/_react["default"].createElement(_Stepper["default"], {
              steps: steps7,
              activeStep: 0,
              fit: _constants.FitMode.Stretched,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 165,
                columnNumber: 9
              }
            })), driver = _render12.driver;
            _context12.t0 = expect;
            _context12.next = 4;
            return driver.getFit();
          case 4:
            _context12.t1 = _context12.sent;
            (0, _context12.t0)(_context12.t1).toBe(_constants.FitMode.Stretched);
          case 6:
          case "end":
            return _context12.stop();
        }
      }, _callee12);
    })));
  });
});