"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 _Range = _interopRequireDefault(require("../Range"));
var _Input = _interopRequireDefault(require("../../Input"));
var _NumberInput = _interopRequireDefault(require("../../NumberInput"));
var _DatePicker = _interopRequireDefault(require("../../DatePicker"));
var _unit = require("../../utils/test-utils/unit");
var _RangeUni = require("../Range.uni.driver");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Range/test/Range.spec.jsx";
describe(_Range["default"].displayName, function () {
  describe('[async]', function () {
    runTests((0, _unit.createRendererWithUniDriver)(_RangeUni.rangeUniDriverFactory));
  });
  function runTests(render) {
    var _this = this;
    afterEach(_unit.cleanup);
    it('should work with datePickers', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
      var onChange, dataHook, _render, driver;
      return _regenerator["default"].wrap(function _callee$(_context) {
        while (1) switch (_context.prev = _context.next) {
          case 0:
            onChange = vi.fn();
            dataHook = 'compHook';
            _render = render(/*#__PURE__*/_react["default"].createElement(_Range["default"], {
              dataHook: dataHook,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 25,
                columnNumber: 9
              }
            }, /*#__PURE__*/_react["default"].createElement(_DatePicker["default"], {
              onChange: onChange,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 26,
                columnNumber: 11
              }
            }), /*#__PURE__*/_react["default"].createElement(_DatePicker["default"], {
              onChange: onChange,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 27,
                columnNumber: 11
              }
            }))), driver = _render.driver;
            _context.t0 = expect;
            _context.next = 6;
            return driver.exists();
          case 6:
            _context.t1 = _context.sent;
            (0, _context.t0)(_context.t1).toBe(true);
          case 8:
          case "end":
            return _context.stop();
        }
      }, _callee);
    })));
    it('should contain both inputs', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2() {
      var _render2, driver;
      return _regenerator["default"].wrap(function _callee2$(_context2) {
        while (1) switch (_context2.prev = _context2.next) {
          case 0:
            _render2 = render(/*#__PURE__*/_react["default"].createElement(_Range["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 36,
                columnNumber: 9
              }
            }, /*#__PURE__*/_react["default"].createElement(_Input["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 37,
                columnNumber: 11
              }
            }), /*#__PURE__*/_react["default"].createElement(_Input["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 38,
                columnNumber: 11
              }
            }))), driver = _render2.driver;
            _context2.t0 = expect;
            _context2.next = 4;
            return driver.hasInput();
          case 4:
            _context2.t1 = _context2.sent;
            (0, _context2.t0)(_context2.t1).toBe(true);
          case 6:
          case "end":
            return _context2.stop();
        }
      }, _callee2);
    })));
    it('should contain label', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee3() {
      var _render3, driver;
      return _regenerator["default"].wrap(function _callee3$(_context3) {
        while (1) switch (_context3.prev = _context3.next) {
          case 0:
            _render3 = render(/*#__PURE__*/_react["default"].createElement(_Range["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 47,
                columnNumber: 9
              }
            }, /*#__PURE__*/_react["default"].createElement("label", {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 48,
                columnNumber: 11
              }
            }, "Label example"), /*#__PURE__*/_react["default"].createElement(_Input["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 49,
                columnNumber: 11
              }
            }), /*#__PURE__*/_react["default"].createElement(_Input["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 50,
                columnNumber: 11
              }
            }))), driver = _render3.driver;
            _context3.t0 = expect;
            _context3.next = 4;
            return driver.hasLabel();
          case 4:
            _context3.t1 = _context3.sent;
            (0, _context3.t0)(_context3.t1).toBe(true);
          case 6:
          case "end":
            return _context3.stop();
        }
      }, _callee3);
    })));
    it('should pass onFocus events to inputs', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee4() {
      var onFocusFirstInputCallback, onFocusLastInputCallback, _render4, driver;
      return _regenerator["default"].wrap(function _callee4$(_context4) {
        while (1) switch (_context4.prev = _context4.next) {
          case 0:
            onFocusFirstInputCallback = vi.fn();
            onFocusLastInputCallback = vi.fn();
            _render4 = render(/*#__PURE__*/_react["default"].createElement(_Range["default"], {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 62,
                columnNumber: 9
              }
            }, /*#__PURE__*/_react["default"].createElement("label", {
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 63,
                columnNumber: 11
              }
            }, "Label example"), /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
              onFocus: onFocusFirstInputCallback,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 64,
                columnNumber: 11
              }
            }), /*#__PURE__*/_react["default"].createElement(_NumberInput["default"], {
              onFocus: onFocusLastInputCallback,
              __self: _this,
              __source: {
                fileName: _jsxFileName,
                lineNumber: 65,
                columnNumber: 11
              }
            }))), driver = _render4.driver;
            _context4.next = 5;
            return driver.clickFirstInput();
          case 5:
            _context4.next = 7;
            return driver.clickLastInput();
          case 7:
            expect(onFocusFirstInputCallback).toHaveBeenCalled();
            expect(onFocusLastInputCallback).toHaveBeenCalled();
          case 9:
          case "end":
            return _context4.stop();
        }
      }, _callee4);
    })));
  }
});