1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | var _exportNames = {
|
7 | renderHook: true,
|
8 | act: true,
|
9 | cleanup: true,
|
10 | addCleanup: true,
|
11 | removeCleanup: true,
|
12 | suppressErrorOutput: true
|
13 | };
|
14 | exports.suppressErrorOutput = exports.renderHook = exports.removeCleanup = exports.cleanup = exports.addCleanup = exports.act = void 0;
|
15 |
|
16 | var _react = require("./types/react");
|
17 |
|
18 | Object.keys(_react).forEach(function (key) {
|
19 | if (key === "default" || key === "__esModule") return;
|
20 | if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
21 | if (key in exports && exports[key] === _react[key]) return;
|
22 | Object.defineProperty(exports, key, {
|
23 | enumerable: true,
|
24 | get: function () {
|
25 | return _react[key];
|
26 | }
|
27 | });
|
28 | });
|
29 | const renderers = [{
|
30 | required: 'react-test-renderer',
|
31 | renderer: './native/pure'
|
32 | }, {
|
33 | required: 'react-dom',
|
34 | renderer: './dom/pure'
|
35 | }];
|
36 |
|
37 | function hasDependency(name) {
|
38 | try {
|
39 | require(name);
|
40 |
|
41 | return true;
|
42 | } catch {
|
43 | return false;
|
44 | }
|
45 | }
|
46 |
|
47 | function getRenderer() {
|
48 | const validRenderer = renderers.find(({
|
49 | required
|
50 | }) => hasDependency(required));
|
51 |
|
52 | if (validRenderer) {
|
53 |
|
54 | return require(validRenderer.renderer);
|
55 | } else {
|
56 | const options = renderers.map(({
|
57 | required
|
58 | }) => ` - ${required}`).sort((a, b) => a.localeCompare(b)).join('\n');
|
59 | throw new Error(`Could not auto-detect a React renderer. Are you sure you've installed one of the following\n${options}\nIf you are using a bundler, please update your imports to use a specific renderer.\nFor instructions see: https://react-hooks-testing-library.com/installation#being-specific`);
|
60 | }
|
61 | }
|
62 |
|
63 | const {
|
64 | renderHook,
|
65 | act,
|
66 | cleanup,
|
67 | addCleanup,
|
68 | removeCleanup,
|
69 | suppressErrorOutput
|
70 | } = getRenderer();
|
71 | exports.suppressErrorOutput = suppressErrorOutput;
|
72 | exports.removeCleanup = removeCleanup;
|
73 | exports.addCleanup = addCleanup;
|
74 | exports.cleanup = cleanup;
|
75 | exports.act = act;
|
76 | exports.renderHook = renderHook; |
\ | No newline at end of file |