"use strict";

require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
var _Arc = _interopRequireDefault(require("../Arc"));
var _utils = require("../utils");
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('Arc', function () {
  test('should return a svg node reference for `componentRef`', function () {
    var ref = jest.fn();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Arc["default"], {
      componentRef: ref
    }));
    var expected = 'svg';
    var actual = ref.mock.calls[0][0].nodeName;
    expect(actual).toBe(expected);
  });
  test('should have black path color by default', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Arc["default"], {
      "data-testid": "arc"
    }));
    var svgPath = _react.screen.getByTestId('arc').children.item(0);
    var expected = '#000000';
    expect(svgPath).toHaveAttribute('stroke', expected);
  });
  test('should change path color when `color` prop is defined', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Arc["default"], {
      color: "#00FF00",
      "data-testid": "arc"
    }));
    var svgPath = _react.screen.getByTestId('arc').children.item(0);
    var expected = '#00FF00';
    expect(svgPath).toHaveAttribute('stroke', expected);
  });
  test('should call `onClick` when path is clicked', /*#__PURE__*/_asyncToGenerator(function* () {
    var handleClick = jest.fn();
    var user = _userEvent["default"].setup();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Arc["default"], {
      "data-testid": "arc",
      onClick: handleClick
    }));
    var clickablePath = _react.screen.getByTestId('arc').children.item(1);
    yield user.click(clickablePath);
    var expected = {
      type: 'click'
    };
    var actual = handleClick.mock.calls.length && handleClick.mock.calls[0][0];
    expect(actual).toMatchObject(expected);
  }));
  test('should have a `stroke-width=9` by default', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Arc["default"], {
      "data-testid": "arc"
    }));
    var svgPath = _react.screen.getByTestId('arc').children.item(0);
    var expected = '9';
    expect(svgPath).toHaveAttribute('stroke-width', expected);
  });
  test('should have a custom `stroke-width`', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Arc["default"], {
      "data-testid": "arc",
      strokeWidth: 20
    }));
    var svgPath = _react.screen.getByTestId('arc').children.item(0);
    var expected = '20';
    expect(svgPath).toHaveAttribute('stroke-width', expected);
  });
  describe('utils', function () {
    test('positionToAngle should return a positive number if `x>0` and `y>0`', function () {
      var angle = (0, _utils.positionToAngle)({
        x: 75,
        y: 200
      }, 294);
      expect(angle).toBeGreaterThan(0);
    });
    test('positionToAngle should return a positive number if `x<0` and `y<0`', function () {
      var angle = (0, _utils.positionToAngle)({
        x: -75,
        y: -200
      }, 294);
      expect(angle).toBeGreaterThan(0);
    });
  });
});