@enact/ui
Version:
A collection of simplified unstyled cross-platform UI components for Enact
56 lines (55 loc) • 2.87 kB
JavaScript
;
require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _Scroller = _interopRequireDefault(require("../Scroller"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 () {
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
"data-testid": "scroller",
horizontalScrollbar: "visible",
verticalScrollbar: "visible",
children: contents
}));
var horizontalScrollbar = _react.screen.getByTestId('scroller').children.item(1);
var verticalScrollbar = _react.screen.getByTestId('scroller').children.item(0).children.item(1);
expect(horizontalScrollbar).toBeInTheDocument();
expect(verticalScrollbar).toBeInTheDocument();
});
test('should render only vertical scrollbar when \'verticalScrollbar\' is "visible" and \'horizontalScrollbar\' is "hidden"', function () {
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
"data-testid": "scroller",
horizontalScrollbar: "hidden",
verticalScrollbar: "visible",
children: contents
}));
var horizontalScrollbar = _react.screen.getByTestId('scroller').children.item(1);
var verticalScrollbar = _react.screen.getByTestId('scroller').children.item(0).children.item(1);
expect(horizontalScrollbar).toBeNull();
expect(verticalScrollbar).toBeInTheDocument();
});
test('should not render any scrollbar when \'horizontalScrollbar\' and \'verticalScrollbar\' are "hidden"', function () {
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Scroller["default"], {
"data-testid": "scroller",
horizontalScrollbar: "hidden",
verticalScrollbar: "hidden",
children: contents
}));
var horizontalScrollbar = _react.screen.getByTestId('scroller').children.item(1);
var verticalScrollbar = _react.screen.getByTestId('scroller').children.item(0).children.item(1);
expect(horizontalScrollbar).toBeNull();
expect(verticalScrollbar).toBeNull();
});
});
});