"use strict";

require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _WindDirectionControl = _interopRequireDefault(require("../WindDirectionControl"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
describe('WindDirectionControl Specs', function () {
  test('should change value when navigating to the second arc segment', function () {
    var handleChange = jest.fn();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_WindDirectionControl["default"], {
      onChange: handleChange
    }));
    var arcPicker = _react.screen.getByRole('slider');
    _react.fireEvent.keyDown(arcPicker.children.item(1).children.item(0), {
      keyCode: 38
    });
    var expected = 'airRight';
    var actual = handleChange.mock.calls[0][0].value;
    expect(actual).toBe(expected);
  });
  test('should change value when navigating to the third arc segment', function () {
    var handleChange = jest.fn();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_WindDirectionControl["default"], {
      onChange: handleChange
    }));
    var arcPicker = _react.screen.getByRole('slider');
    _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 expected = 'airUp';
    var actual = handleChange.mock.calls[1][0].value;
    expect(actual).toBe(expected);
  });
  test('should change value when navigating to the first arc segment', function () {
    var handleChange = jest.fn();
    // initiate WindDirectionControl with second arc selected
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_WindDirectionControl["default"], {
      onChange: handleChange,
      value: "airRight"
    }));
    var arcPicker = _react.screen.getByRole('slider');
    _react.fireEvent.keyDown(arcPicker.children.item(1).children.item(0), {
      keyCode: 40
    });
    var expected = 'airDown';
    var actual = handleChange.mock.calls[0][0].value;
    expect(actual).toBe(expected);
  });
  test('should not call onChange handler when disabled', function () {
    var handleChange = jest.fn();
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_WindDirectionControl["default"], {
      disabled: true,
      onChange: handleChange
    }));
    var arcPicker = _react.screen.getByRole('slider');
    _react.fireEvent.keyDown(arcPicker.children.item(1).children.item(0), {
      keyCode: 38
    });
    expect(handleChange).not.toHaveBeenCalled();
  });
});