"use strict";

require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _ArcPicker = _interopRequireDefault(require("../ArcPicker"));
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); }); }; }
var blur = function blur(arcPicker) {
  return _react.fireEvent.blur(arcPicker);
};
describe('ArcPicker Specs', function () {
  test('should change value when navigating to a certain arc segment', function () {
    var handleChange = jest.fn();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArcPicker["default"], {
      onChange: handleChange,
      children: [1, 2, 3, 4]
    }));
    var arcPicker = _react.screen.getByRole('slider');
    _react.fireEvent.keyDown(arcPicker.children.item(1).children.item(0), {
      keyCode: 38
    });
    var expected = 2;
    var actual = handleChange.mock.calls[0][0].value;
    expect(actual).toBe(expected);
    _react.fireEvent.keyDown(arcPicker.children.item(1).children.item(0), {
      keyCode: 38
    });
    _react.fireEvent.keyDown(arcPicker.children.item(1).children.item(0), {
      keyCode: 38
    });
    var secondExpected = 4;
    var secondActual = handleChange.mock.calls[2][0].value;
    expect(secondActual).toBe(secondExpected);
  });
  test('should not run the onChange handler when disabled', function () {
    var handleChange = jest.fn();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArcPicker["default"], {
      disabled: true,
      onChange: handleChange,
      children: [1, 2, 3, 4]
    }));
    var arcPicker = _react.screen.getByRole('slider');
    _react.fireEvent.keyDown(arcPicker.children.item(1).children.item(0), {
      keyCode: 38
    });
    expect(handleChange).not.toHaveBeenCalled();
  });
  test('should have `strokeWidth=6` by default', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArcPicker["default"], {
      children: [1, 2, 3, 4]
    }));
    var arcPicker = _react.screen.getByRole('slider');
    var expected = '6';
    expect(arcPicker).toHaveAttribute('stroke-width', expected);
  });
  test('should set `strokeWidth`', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArcPicker["default"], {
      strokeWidth: 10,
      children: [1, 2, 3, 4]
    }));
    var arcPicker = _react.screen.getByRole('slider');
    var expected = '10';
    expect(arcPicker).toHaveAttribute('stroke-width', expected);
  });
  test('should set foreground color', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArcPicker["default"], {
      foregroundColor: "#FF0000",
      children: [1, 2, 3, 4]
    }));
    var foregroundColor = _react.screen.getByRole('slider').children.item(0).children.item(0);
    var expected = '#FF0000';
    expect(foregroundColor).toHaveAttribute('stroke', expected);
  });
  test('should have `#343434` foreground color with `carbon` skin', /*#__PURE__*/_asyncToGenerator(function* () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArcPicker["default"], {
      skin: "carbon",
      children: [1, 2, 3, 4]
    }));
    var arcPicker = _react.screen.getByRole('slider');
    var foregroundColor = _react.screen.getByRole('slider').children.item(0).children.item(0);

    // on render arcPicker is focused, so blur is called
    blur(arcPicker);
    var expected = '#343434';
    expect(foregroundColor).toHaveAttribute('stroke', expected);
  }));
  test('should have `#ffffff` foreground color with night mode', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArcPicker["default"], {
      skinVariants: {
        night: true
      },
      children: [1, 2, 3, 4]
    }));
    var foregroundColor = _react.screen.getByRole('slider').children.item(0).children.item(0);
    var expected = '#ffffff';
    expect(foregroundColor).toHaveAttribute('stroke', expected);
  });
});