"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 _ = _interopRequireDefault(require(".."));

var _uiTestUtils = require("@instructure/ui-test-utils");

var _locator = _interopRequireDefault(require("@instructure/ui-number-input/lib/components/NumberInput/locator"));

var _react = _interopRequireDefault(require("react"));

var clear =
/*#__PURE__*/
function () {
  var _ref = (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee(input) {
    return _regenerator.default.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return input.input({
              target: {
                value: ''
              }
            });

          case 2:
            return _context.abrupt("return");

          case 3:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));

  return function clear(_x) {
    return _ref.apply(this, arguments);
  };
}();

describe('ExtraAttempts', function () {
  var labelText = 'Additional attempts';
  it('should render an input with a label',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee2() {
    var input;
    return _regenerator.default.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            _context2.next = 2;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 0,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 2:
            _context2.next = 4;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 4:
            input = _context2.sent;
            (0, _uiTestUtils.expect)(input).to.exist();

          case 6:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  })));
  it('should accept a valid input',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee3() {
    var input;
    return _regenerator.default.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            _context3.next = 2;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 0,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 2:
            _context3.next = 4;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 4:
            input = _context3.sent;
            _context3.next = 7;
            return clear(input);

          case 7:
            _context3.next = 9;
            return input.typeIn('8');

          case 9:
            _context3.next = 11;
            return input.blur();

          case 11:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(8);

          case 12:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  })));
  it('should accept a value above max and reset on blur with an error message',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee4() {
    var input, outOfRange;
    return _regenerator.default.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            _context4.next = 2;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 20,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 2:
            _context4.next = 4;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 4:
            input = _context4.sent;
            outOfRange = '26';
            _context4.next = 8;
            return clear(input);

          case 8:
            _context4.next = 10;
            return input.typeIn(outOfRange);

          case 10:
            _context4.next = 12;
            return input.blur();

          case 12:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(20);
            _context4.t0 = _uiTestUtils.expect;
            _context4.next = 16;
            return (0, _uiTestUtils.findWithText)("".concat(outOfRange, " is above the maximum of 20."));

          case 16:
            _context4.t1 = _context4.sent;
            (0, _context4.t0)(_context4.t1).to.exist();

          case 18:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  })));
  it('should accept a value below 0 and reset on blur with an error message',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee5() {
    var input, outOfRange;
    return _regenerator.default.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            _context5.next = 2;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 20,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 2:
            _context5.next = 4;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 4:
            input = _context5.sent;
            outOfRange = '-5';
            _context5.next = 8;
            return clear(input);

          case 8:
            _context5.next = 10;
            return input.typeIn(outOfRange);

          case 10:
            _context5.next = 12;
            return input.blur();

          case 12:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(0);
            _context5.t0 = _uiTestUtils.expect;
            _context5.next = 16;
            return (0, _uiTestUtils.findWithText)("".concat(outOfRange, " is below the minimum of 0."));

          case 16:
            _context5.t1 = _context5.sent;
            (0, _context5.t0)(_context5.t1).to.exist();

          case 18:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  })));
  it('should display a value above max when passed as a prop, and clamp on blur',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee6() {
    var extraAttempts, max, input;
    return _regenerator.default.wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            extraAttempts = 12;
            max = 10;
            _context6.next = 4;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: extraAttempts,
              maxExtraAttempts: max,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 4:
            _context6.next = 6;
            return (0, _uiTestUtils.findWithLabel)(labelText, {
              exact: false
            });

          case 6:
            input = _context6.sent;
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(extraAttempts);
            _context6.t0 = _uiTestUtils.expect;
            _context6.next = 11;
            return (0, _uiTestUtils.findWithText)("".concat(extraAttempts, " is above the maximum of ").concat(max, "."));

          case 11:
            _context6.t1 = _context6.sent;
            (0, _context6.t0)(_context6.t1).to.exist();
            _context6.next = 15;
            return input.blur();

          case 15:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(max);

          case 16:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  })));
  it('should display a value below 0 when passed as a prop, and clamp on blur',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee7() {
    var extraAttempts, input;
    return _regenerator.default.wrap(function _callee7$(_context7) {
      while (1) {
        switch (_context7.prev = _context7.next) {
          case 0:
            extraAttempts = -12;
            _context7.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: extraAttempts,
              maxExtraAttempts: 10,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 3:
            _context7.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText, {
              exact: false
            });

          case 5:
            input = _context7.sent;
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(extraAttempts);
            _context7.t0 = _uiTestUtils.expect;
            _context7.next = 10;
            return (0, _uiTestUtils.findWithText)("".concat(extraAttempts, " is below the minimum of 0."));

          case 10:
            _context7.t1 = _context7.sent;
            (0, _context7.t0)(_context7.t1).to.exist();
            _context7.next = 14;
            return input.blur();

          case 14:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(0);

          case 15:
          case "end":
            return _context7.stop();
        }
      }
    }, _callee7);
  })));
  it('should accept a non-number input and reset on blur with an error message',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee8() {
    var input, invalidValue, errMsg;
    return _regenerator.default.wrap(function _callee8$(_context8) {
      while (1) {
        switch (_context8.prev = _context8.next) {
          case 0:
            _context8.next = 2;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 20,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 2:
            _context8.next = 4;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 4:
            input = _context8.sent;
            invalidValue = 'apple';
            _context8.next = 8;
            return clear(input);

          case 8:
            _context8.next = 10;
            return input.typeIn('6');

          case 10:
            _context8.next = 12;
            return clear(input);

          case 12:
            _context8.next = 14;
            return input.typeIn(invalidValue);

          case 14:
            _context8.next = 16;
            return input.blur();

          case 16:
            errMsg = "".concat(invalidValue, " is not a valid number.");
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(6);
            _context8.t0 = _uiTestUtils.expect;
            _context8.next = 21;
            return (0, _uiTestUtils.findWithText)(errMsg);

          case 21:
            _context8.t1 = _context8.sent;
            (0, _context8.t0)(_context8.t1).to.exist();

          case 23:
          case "end":
            return _context8.stop();
        }
      }
    }, _callee8);
  })));
  it('should not show an error message when the input is blank',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee9() {
    var input, errElement;
    return _regenerator.default.wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            _context9.next = 2;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 20,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 2:
            _context9.next = 4;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 4:
            input = _context9.sent;
            _context9.next = 7;
            return clear(input);

          case 7:
            _context9.next = 9;
            return (0, _uiTestUtils.findWithText)('is not a valid number.', {
              expectEmpty: true
            });

          case 9:
            errElement = _context9.sent;
            (0, _uiTestUtils.expect)(errElement).not.to.exist();

          case 11:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9);
  })));
  it('should remove error message after valid input',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee10() {
    var input, invalidValue, errorMsg;
    return _regenerator.default.wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            _context10.next = 2;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 20,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 2:
            _context10.next = 4;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 4:
            input = _context10.sent;
            invalidValue = 'apple';
            _context10.next = 8;
            return clear(input);

          case 8:
            _context10.next = 10;
            return input.typeIn(invalidValue);

          case 10:
            _context10.next = 12;
            return clear(input);

          case 12:
            _context10.next = 14;
            return input.typeIn('6');

          case 14:
            _context10.next = 16;
            return input.blur();

          case 16:
            errorMsg = "".concat(invalidValue, " is not a valid number.");
            _context10.t0 = _uiTestUtils.expect;
            _context10.next = 20;
            return (0, _uiTestUtils.findWithText)(errorMsg, {
              expectEmpty: true
            });

          case 20:
            _context10.t1 = _context10.sent;
            (0, _context10.t0)(_context10.t1).not.to.exist();

          case 22:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10);
  })));
  it('should callback a valid input',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee11() {
    var onChange, input;
    return _regenerator.default.wrap(function _callee11$(_context11) {
      while (1) {
        switch (_context11.prev = _context11.next) {
          case 0:
            onChange = (0, _uiTestUtils.spy)();
            _context11.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 0,
              onChange: onChange
            }));

          case 3:
            _context11.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context11.sent;
            _context11.next = 8;
            return clear(input);

          case 8:
            _context11.next = 10;
            return input.typeIn('4');

          case 10:
            _context11.next = 12;
            return input.blur();

          case 12:
            (0, _uiTestUtils.expect)(onChange).to.have.been.calledWith(4);

          case 13:
          case "end":
            return _context11.stop();
        }
      }
    }, _callee11);
  })));
  it('should callback the most recent valid input on invalid input',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee12() {
    var onChange, input, invalidValue;
    return _regenerator.default.wrap(function _callee12$(_context12) {
      while (1) {
        switch (_context12.prev = _context12.next) {
          case 0:
            onChange = (0, _uiTestUtils.spy)();
            _context12.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 0,
              onChange: onChange
            }));

          case 3:
            _context12.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context12.sent;
            invalidValue = '!392afs09';
            _context12.next = 9;
            return clear(input);

          case 9:
            _context12.next = 11;
            return input.typeIn('7');

          case 11:
            _context12.next = 13;
            return input.blur();

          case 13:
            (0, _uiTestUtils.expect)(onChange).to.have.been.calledWith(7);
            _context12.next = 16;
            return clear(input);

          case 16:
            _context12.next = 18;
            return input.typeIn(invalidValue);

          case 18:
            _context12.next = 20;
            return input.blur();

          case 20:
            (0, _uiTestUtils.expect)(onChange).to.have.been.calledWith(7);

          case 21:
          case "end":
            return _context12.stop();
        }
      }
    }, _callee12);
  })));
  it('should respond correctly to up-and-down buttons',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee13() {
    var onChange, input, numberInput, arrows, upButton, downButton;
    return _regenerator.default.wrap(function _callee13$(_context13) {
      while (1) {
        switch (_context13.prev = _context13.next) {
          case 0:
            onChange = (0, _uiTestUtils.spy)();
            _context13.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 9,
              onChange: onChange
            }));

          case 3:
            _context13.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context13.sent;
            _context13.next = 8;
            return _locator.default.find();

          case 8:
            numberInput = _context13.sent;
            _context13.next = 11;
            return numberInput.findArrowButtons();

          case 11:
            arrows = _context13.sent;
            upButton = arrows[0];
            downButton = arrows[1];
            _context13.next = 16;
            return upButton.mouseDown();

          case 16:
            _context13.next = 18;
            return input.blur();

          case 18:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(10);
            _context13.next = 21;
            return downButton.mouseDown();

          case 21:
            _context13.next = 23;
            return input.blur();

          case 23:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(9);

          case 24:
          case "end":
            return _context13.stop();
        }
      }
    }, _callee13);
  })));
  it('should respond correctly to arrow keys',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee14() {
    var onChange, input;
    return _regenerator.default.wrap(function _callee14$(_context14) {
      while (1) {
        switch (_context14.prev = _context14.next) {
          case 0:
            onChange = (0, _uiTestUtils.spy)();
            _context14.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 2,
              onChange: onChange
            }));

          case 3:
            _context14.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context14.sent;
            _context14.next = 8;
            return input.keyDown('up');

          case 8:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(3);
            _context14.next = 11;
            return input.keyDown('down');

          case 11:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(2);

          case 12:
          case "end":
            return _context14.stop();
        }
      }
    }, _callee14);
  })));
  it('should ignore up-and-down button events when current value invalid',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee15() {
    var onChange, input, numberInput, arrows, upButton, downButton, invalidValue;
    return _regenerator.default.wrap(function _callee15$(_context15) {
      while (1) {
        switch (_context15.prev = _context15.next) {
          case 0:
            onChange = (0, _uiTestUtils.spy)();
            _context15.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              onChange: onChange
            }));

          case 3:
            _context15.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context15.sent;
            _context15.next = 8;
            return _locator.default.find();

          case 8:
            numberInput = _context15.sent;
            _context15.next = 11;
            return numberInput.findArrowButtons();

          case 11:
            arrows = _context15.sent;
            upButton = arrows[0];
            downButton = arrows[1];
            invalidValue = 'ksf0sf90afs';
            _context15.next = 17;
            return clear(input);

          case 17:
            _context15.next = 19;
            return input.typeIn(invalidValue);

          case 19:
            _context15.next = 21;
            return upButton.click();

          case 21:
            _context15.next = 23;
            return downButton.click();

          case 23:
            (0, _uiTestUtils.expect)(input.value()).to.equal(invalidValue);

          case 24:
          case "end":
            return _context15.stop();
        }
      }
    }, _callee15);
  })));
  it('should ignore arrow keys when current value invalid',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee16() {
    var onChange, input, invalidValue;
    return _regenerator.default.wrap(function _callee16$(_context16) {
      while (1) {
        switch (_context16.prev = _context16.next) {
          case 0:
            onChange = (0, _uiTestUtils.spy)();
            _context16.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              onChange: onChange
            }));

          case 3:
            _context16.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context16.sent;
            _context16.next = 8;
            return clear(input);

          case 8:
            invalidValue = 'klj3jlk4j3kl2j';
            _context16.next = 11;
            return input.typeIn(invalidValue);

          case 11:
            _context16.next = 13;
            return input.keyDown('up');

          case 13:
            _context16.next = 15;
            return input.keyDown('down');

          case 15:
            (0, _uiTestUtils.expect)(input.value()).to.equal(invalidValue);

          case 16:
          case "end":
            return _context16.stop();
        }
      }
    }, _callee16);
  })));
  it('should reset to max on up-and-down button events when input above max',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee17() {
    var onChange, input, numberInput, arrows, upButton, downButton;
    return _regenerator.default.wrap(function _callee17$(_context17) {
      while (1) {
        switch (_context17.prev = _context17.next) {
          case 0:
            onChange = (0, _uiTestUtils.stub)();
            _context17.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 10,
              onChange: onChange
            }));

          case 3:
            _context17.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context17.sent;
            _context17.next = 8;
            return _locator.default.find();

          case 8:
            numberInput = _context17.sent;
            _context17.next = 11;
            return numberInput.findArrowButtons();

          case 11:
            arrows = _context17.sent;
            upButton = arrows[0];
            downButton = arrows[1];
            _context17.next = 16;
            return clear(input);

          case 16:
            _context17.next = 18;
            return input.typeIn('15');

          case 18:
            _context17.next = 20;
            return upButton.mouseDown();

          case 20:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(10);
            _context17.next = 23;
            return clear(input);

          case 23:
            _context17.next = 25;
            return input.typeIn('15');

          case 25:
            _context17.next = 27;
            return downButton.mouseDown();

          case 27:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(10);

          case 28:
          case "end":
            return _context17.stop();
        }
      }
    }, _callee17);
  })));
  it('should reset to min on up-and-down button events when input below 0',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee18() {
    var onChange, input, numberInput, arrows, upButton, downButton;
    return _regenerator.default.wrap(function _callee18$(_context18) {
      while (1) {
        switch (_context18.prev = _context18.next) {
          case 0:
            onChange = (0, _uiTestUtils.stub)();
            _context18.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 10,
              onChange: onChange
            }));

          case 3:
            _context18.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context18.sent;
            _context18.next = 8;
            return _locator.default.find();

          case 8:
            numberInput = _context18.sent;
            _context18.next = 11;
            return numberInput.findArrowButtons();

          case 11:
            arrows = _context18.sent;
            upButton = arrows[0];
            downButton = arrows[1];
            _context18.next = 16;
            return clear(input);

          case 16:
            _context18.next = 18;
            return input.typeIn('-15');

          case 18:
            _context18.next = 20;
            return upButton.mouseDown();

          case 20:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(0);
            _context18.next = 23;
            return clear(input);

          case 23:
            _context18.next = 25;
            return input.typeIn('-15');

          case 25:
            _context18.next = 27;
            return downButton.mouseDown();

          case 27:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(0);

          case 28:
          case "end":
            return _context18.stop();
        }
      }
    }, _callee18);
  })));
  it('should reset to max on arrow key events when input above max',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee19() {
    var onChange, input;
    return _regenerator.default.wrap(function _callee19$(_context19) {
      while (1) {
        switch (_context19.prev = _context19.next) {
          case 0:
            onChange = (0, _uiTestUtils.stub)();
            _context19.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 10,
              onChange: onChange
            }));

          case 3:
            _context19.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context19.sent;
            _context19.next = 8;
            return clear(input);

          case 8:
            _context19.next = 10;
            return input.typeIn('25');

          case 10:
            _context19.next = 12;
            return input.keyDown('up');

          case 12:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(10);
            _context19.next = 15;
            return clear(input);

          case 15:
            _context19.next = 17;
            return input.typeIn('25');

          case 17:
            _context19.next = 19;
            return input.keyDown('down');

          case 19:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(10);

          case 20:
          case "end":
            return _context19.stop();
        }
      }
    }, _callee19);
  })));
  it('should reset to min on arrow key events when input below 0',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee20() {
    var onChange, input;
    return _regenerator.default.wrap(function _callee20$(_context20) {
      while (1) {
        switch (_context20.prev = _context20.next) {
          case 0:
            onChange = (0, _uiTestUtils.stub)();
            _context20.next = 3;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 10,
              onChange: onChange
            }));

          case 3:
            _context20.next = 5;
            return (0, _uiTestUtils.findWithLabel)(labelText);

          case 5:
            input = _context20.sent;
            _context20.next = 8;
            return clear(input);

          case 8:
            _context20.next = 10;
            return input.typeIn('-15');

          case 10:
            _context20.next = 12;
            return input.keyDown('up');

          case 12:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(0);
            _context20.next = 15;
            return clear(input);

          case 15:
            _context20.next = 17;
            return input.typeIn('-15');

          case 17:
            _context20.next = 19;
            return input.keyDown('down');

          case 19:
            (0, _uiTestUtils.expect)(Number(input.value())).to.equal(0);

          case 20:
          case "end":
            return _context20.stop();
        }
      }
    }, _callee20);
  })));
  it('should be accessible',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee21() {
    return _regenerator.default.wrap(function _callee21$(_context21) {
      while (1) {
        switch (_context21.prev = _context21.next) {
          case 0:
            _context21.next = 2;
            return (0, _uiTestUtils.mount)(_react.default.createElement(_.default, {
              extraAttempts: 5,
              maxExtraAttempts: 10,
              onChange: (0, _uiTestUtils.stub)()
            }));

          case 2:
            _context21.t0 = _uiTestUtils.expect;
            _context21.next = 5;
            return (0, _uiTestUtils.accessible)();

          case 5:
            _context21.t1 = _context21.sent;
            (0, _context21.t0)(_context21.t1).to.be.true();

          case 7:
          case "end":
            return _context21.stop();
        }
      }
    }, _callee21);
  })));
});