@yoroi/common
Version:
The Common package of Yoroi SDK
24 lines (23 loc) • 1.5 kB
JavaScript
;
var _reactNative = require("@testing-library/react-native");
var React = _interopRequireWildcard(require("react"));
var _ErrorBoundary = require("./ErrorBoundary");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const ProblematicChild = () => {
throw new Error('Test error');
};
describe('ErrorBoundary', () => {
test('should display an error message when a child component throws an error', async () => {
const {
getByTestId
} = (0, _reactNative.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_ErrorBoundary.ErrorBoundary, {
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProblematicChild, {})
}));
await (0, _reactNative.waitFor)(() => {
expect(getByTestId('hasError')).toBeDefined();
});
expect(getByTestId('hasError').props.children[0].props.children).toEqual('hasError');
});
});
//# sourceMappingURL=ErrorBoundary.test.js.map