@enact/i18n
Version:
Internationalization support for Enact using iLib
41 lines (40 loc) • 1.47 kB
JavaScript
;
require("@testing-library/jest-dom");
var _react = require("@testing-library/react");
var _I18nDecorator = require("../../I18nDecorator");
var _resBundle = require("../../src/resBundle");
var _$L = require("../$L");
var _jsxRuntime = require("react/jsx-runtime");
describe('$L', function () {
test('should get the key string when there is no translated value', function () {
var expected = 'hello';
var Component = function Component(props) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: props.className,
children: (0, _$L.$L)(expected)
});
};
var Wrapped = (0, _I18nDecorator.I18nDecorator)({
sync: true
}, Component);
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, {}));
var actual = _react.screen.getByText(expected);
expect(actual).toBeInTheDocument();
});
test('should clear ResBundle with calling `clearResBundle`', function () {
var expected = null;
var Component = function Component(props) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: props.className,
children: (0, _$L.$L)('hello')
});
};
var Wrapped = (0, _I18nDecorator.I18nDecorator)({
sync: true
}, Component);
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapped, {}));
(0, _resBundle.clearResBundle)();
var actual = (0, _resBundle.getResBundle)();
expect(actual).toEqual(expected);
});
});