@enact/ui
Version:
A collection of simplified unstyled cross-platform UI components for Enact
32 lines (31 loc) • 1.25 kB
JavaScript
;
var _react = require("@testing-library/react");
var _react2 = require("react");
var _Announce = _interopRequireDefault(require("../Announce"));
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
describe('Announce', function () {
test('should have an announce method on the component', function () {
var ref = /*#__PURE__*/(0, _react2.createRef)();
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Announce["default"], {
ref: ref
}));
var node = ref.current;
var expected = 'function';
var actual = typeof node.announce;
expect(actual).toBe(expected);
});
test('should update the aria-label with the provided message', function () {
var ref = /*#__PURE__*/(0, _react2.createRef)();
var message = 'message';
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_Announce["default"], {
ref: ref
}));
var node = ref.current;
node.announce(message);
var expected = message;
// since we're manually updating the node in Announce, we have to manually check the node here
var actual = node.alert.getAttribute('aria-label');
expect(actual).toBe(expected);
});
});