"use strict";

require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _ToggleButton = _interopRequireDefault(require("../ToggleButton"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
describe('ToggleButton', function () {
  var textChild = 'TOGGLE ME';
  var toggleOnLabel = 'IT\'S ON!';
  var toggleOffLabel = 'IT\'S OFF!';
  test('should use \'toggleOffLabel\' if toggled off and label provided', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      toggleOffLabel: toggleOffLabel,
      children: textChild
    }));
    var expected = toggleOffLabel;
    var actual = _react.screen.getByRole('button');
    expect(actual).toHaveTextContent(expected);
  });
  test('should use \'toggleOnLabel\' if toggled on and label provided', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      selected: true,
      toggleOnLabel: toggleOnLabel,
      children: textChild
    }));
    var expected = toggleOnLabel;
    var actual = _react.screen.getByRole('button');
    expect(actual).toHaveTextContent(expected);
  });
  test('should use child node for label when \'toggleOffLabel\' is missing', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      toggleOnLabel: toggleOnLabel,
      children: textChild
    }));
    var button = _react.screen.getByRole('button');
    expect(button).toHaveTextContent(textChild);
  });
  test('should use child node for label when \'toggleOnLabel\' is missing', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      selected: true,
      toggleOffLabel: toggleOffLabel,
      children: textChild
    }));
    var button = _react.screen.getByRole('button');
    expect(button).toHaveTextContent(textChild);
  });
  test('should set "aria-pressed" to the value of "selected"', function () {
    (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      selected: false,
      toggleOffLabel: toggleOffLabel,
      children: textChild
    }));
    var expected = 'false';
    var actual = _react.screen.getByRole('button');
    expect(actual).toHaveAttribute('aria-pressed', expected);
  });
});