"use strict";

require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
var _RangePicker = require("../RangePicker");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
describe('RangePicker Specs', function () {
  test('should render a single child with the current value', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RangePicker.RangePicker, {
      max: 20,
      min: -10,
      value: 10
    }));
    var pickerValue = _react.screen.getByRole('spinbutton');
    var expected = '10';
    expect(pickerValue).toHaveTextContent(expected);
  });
  test('should increase by step amount on increment press', /*#__PURE__*/_asyncToGenerator(function* () {
    var user = _userEvent["default"].setup();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RangePicker.RangePicker, {
      defaultValue: 10,
      max: 100,
      min: 0,
      noAnimation: true,
      step: 1
    }));
    yield user.click(_react.screen.getByLabelText("".concat(10, " increase the value")));
    var expected = '11';
    var actual = _react.screen.getByRole('spinbutton');
    expect(actual).toHaveTextContent(expected);
  }));
  test('should decrease by step amount on decrement press', /*#__PURE__*/_asyncToGenerator(function* () {
    var user = _userEvent["default"].setup();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RangePicker.RangePicker, {
      defaultValue: 10,
      max: 100,
      min: 0,
      noAnimation: true,
      step: 1
    }));
    yield user.click(_react.screen.getByLabelText("".concat(10, " decrease the value")));
    var expected = '9';
    var actual = _react.screen.getByRole('spinbutton');
    expect(actual).toHaveTextContent(expected);
  }));
  test('should be disabled when limited to a single value', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_RangePicker.RangePickerBase, {
      max: 0,
      min: 0,
      value: 0
    }));
    var pickerPreviousValue = _react.screen.getByLabelText('0 decrease the value');
    var pickerNextValue = _react.screen.getByLabelText('0 increase the value');
    var expectedAttribute = 'disabled';
    expect(pickerPreviousValue).toHaveAttribute(expectedAttribute);
    expect(pickerNextValue).toHaveAttribute(expectedAttribute);
  });
});