"use strict";

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

var _enzyme = require("enzyme");

var _Scroller = _interopRequireDefault(require("../Scroller"));

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

describe('Scroller', function () {
  var contents;
  beforeEach(function () {
    contents = /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      children: ["Lorem ipsum dolor sit amet, consectetur adipiscing elit.", /*#__PURE__*/(0, _jsxRuntime.jsx)("br", {}), "Aenean id blandit nunc. Donec lacinia nisi vitae mi dictum, eget pulvinar nunc tincidunt. Integer vehicula tempus rutrum. Sed efficitur neque in arcu dignissim cursus."]
    });
  });
  afterEach(function () {
    contents = null;
  });
  describe('Scrollbar visibility', function () {
    test('should render both horizontal and vertical scrollbars when \'horizontalScrollbar\' and \'verticalScrollbar\' are "visible"', function () {
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "visible",
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = 2;
      var actual = subject.find('Scrollbar').length;
      expect(actual).toBe(expected);
    });
    test('should render only vertical scrollbar when \'verticalScrollbar\' is "visible" and \'horizontalScrollbar\' is "hidden"', function () {
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "hidden",
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = 1;
      var actual = subject.find('Scrollbar').length;
      expect(actual).toBe(expected);
    });
    test('should not render any scrollbar when when \'horizontalScrollbar\' and \'verticalScrollbar\' are "hidden"', function () {
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "hidden",
        verticalScrollbar: "hidden",
        children: contents
      }));
      var expected = 0;
      var actual = subject.find('Scrollbar').length;
      expect(actual).toBe(expected);
    });
  });
  describe('Scrollbar accessibility', function () {
    test('should set a custom "aria-label" to the up scroll button in the vertical scrollbar', function () {
      var label = 'custom button aria label';
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "visible",
        scrollUpAriaLabel: label,
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = label;
      var actual = subject.find('ScrollButton').at(0).prop('aria-label');
      expect(actual).toBe(expected);
    });
    test('should set a custom "aria-label" to the down scroll button in the vertical scrollbar', function () {
      var label = 'custom button aria label';
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "visible",
        scrollDownAriaLabel: label,
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = label;
      var actual = subject.find('ScrollButton').at(1).prop('aria-label');
      expect(actual).toBe(expected);
    });
    test('should set a custom "aria-label" to the left scroll button in the horizontal scrollbar', function () {
      var label = 'custom button aria label';
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "visible",
        scrollLeftAriaLabel: label,
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = label;
      var actual = subject.find('ScrollButton').at(2).prop('aria-label');
      expect(actual).toBe(expected);
    });
    test('should set a custom "aria-label" to the right scroll button in the horizontal scrollbar', function () {
      var label = 'custom button aria label';
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "visible",
        scrollRightAriaLabel: label,
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = label;
      var actual = subject.find('ScrollButton').at(3).prop('aria-label');
      expect(actual).toBe(expected);
    });
    test('should set a null string "aria-label" to the up scroll button in the vertical scrollbar', function () {
      var label = '';
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "visible",
        scrollUpAriaLabel: label,
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = label;
      var actual = subject.find('ScrollButton').at(0).prop('aria-label');
      expect(actual).toBe(expected);
    });
    test('should set a null string "aria-label" to the down scroll button in the vertical scrollbar', function () {
      var label = '';
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "visible",
        scrollDownAriaLabel: label,
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = label;
      var actual = subject.find('ScrollButton').at(1).prop('aria-label');
      expect(actual).toBe(expected);
    });
    test('should set a null string "aria-label" to the left scroll button in the horizontal scrollbar', function () {
      var label = '';
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "visible",
        scrollLeftAriaLabel: label,
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = label;
      var actual = subject.find('ScrollButton').at(2).prop('aria-label');
      expect(actual).toBe(expected);
    });
    test('should set a null string "aria-label" to the right scroll button in the horizontal scrollbar', function () {
      var label = '';
      var subject = (0, _enzyme.mount)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
        horizontalScrollbar: "visible",
        scrollRightAriaLabel: label,
        verticalScrollbar: "visible",
        children: contents
      }));
      var expected = label;
      var actual = subject.find('ScrollButton').at(3).prop('aria-label');
      expect(actual).toBe(expected);
    });
  });
});