UNPKG

1.19 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.wrapsIntrinsicElement = wrapsIntrinsicElement;
7exports.default = findOutermostIntrinsic;
8
9/**
10 * checks if a given react wrapper wraps an intrinsic element i.e. a DOM node
11 *
12 * @param {import('enzyme').ReactWrapper} reactWrapper
13 * @returns {boolean} true if the given reactWrapper wraps an intrinsic element
14 */
15function wrapsIntrinsicElement(reactWrapper) {
16 return typeof reactWrapper.type() === 'string';
17}
18
19var warnedOnce = false;
20/**
21 * like ReactWrapper#getDOMNode() but returns a ReactWrapper
22 *
23 * @param {import('enzyme').ReactWrapper} reactWrapper
24 * @returns {import('enzyme').ReactWrapper} the wrapper for the outermost DOM node
25 */
26
27function findOutermostIntrinsic(reactWrapper) {
28 if (!warnedOnce) {
29 warnedOnce = true;
30 console.warn(['Material-UI: the test utils are deprecated, they are no longer present in v5.', 'The helpers were designed to work with enzyme.', 'However, the tests of the core components were moved to react-testing-library.'].join('\n'));
31 }
32
33 return reactWrapper.findWhere(function (n) {
34 return n.exists() && wrapsIntrinsicElement(n);
35 }).first();
36}
\No newline at end of file