"use strict";

var _jsxRuntime = require("react/jsx-runtime");

var _enzyme = require("enzyme");

var _ToggleButton = _interopRequireDefault(require("../ToggleButton"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

describe('ToggleButton', function () {
  var toggleOnLabel = 'IT\'S ON!';
  var toggleOffLabel = 'IT\'S OFF!';
  var textChild = 'TOGGLE ME';
  test('should use \'toggleOffLabel\' if toggled off and label provided', function () {
    var toggleButton = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      toggleOffLabel: toggleOffLabel,
      children: textChild
    }));
    var button = toggleButton.find('Button');
    var expected = toggleOffLabel.toUpperCase();
    var actual = button.text();
    expect(actual).toBe(expected);
  });
  test('should use \'toggleOnLabel\' if toggled on and label provided', function () {
    var toggleButton = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      toggleOnLabel: toggleOnLabel,
      selected: true,
      children: textChild
    }));
    var button = toggleButton.find('Button');
    var expected = toggleOnLabel.toUpperCase();
    var actual = button.text();
    expect(actual).toBe(expected);
  });
  test('should use child node for label when \'toggleOffLabel\' is missing', function () {
    var toggleButton = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      toggleOnLabel: toggleOnLabel,
      children: textChild
    }));
    var button = toggleButton.find('Button');
    var expected = textChild.toUpperCase();
    var actual = button.text();
    expect(actual).toBe(expected);
  });
  test('should use child node for label when \'toggleOnLabel\' is missing', function () {
    var toggleButton = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      toggleOffLabel: toggleOffLabel,
      selected: true,
      children: textChild
    }));
    var button = toggleButton.find('Button');
    var expected = textChild.toUpperCase();
    var actual = button.text();
    expect(actual).toBe(expected);
  });
  test('should set "aria-pressed" to the value of "selected"', function () {
    var toggleButton = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton["default"], {
      toggleOffLabel: toggleOffLabel,
      selected: false,
      children: textChild
    }));
    var expected = false;
    var actual = toggleButton.find({
      role: 'button'
    }).prop('aria-pressed');
    expect(actual).toBe(expected);
  });
});