1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import { shallow as enzymeShallow } from 'enzyme';
|
4 | import until from './until';
|
5 | let warnedOnce = false;
|
6 |
|
7 | export default function createShallow(options1 = {}) {
|
8 | if (!warnedOnce) {
|
9 | warnedOnce = true;
|
10 | 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'));
|
11 | }
|
12 |
|
13 | const {
|
14 | shallow = enzymeShallow,
|
15 | dive = false,
|
16 | untilSelector = false
|
17 | } = options1,
|
18 | other1 = _objectWithoutPropertiesLoose(options1, ["shallow", "dive", "untilSelector"]);
|
19 |
|
20 | const shallowWithContext = function shallowWithContext(node, options2 = {}) {
|
21 | const options = _extends({}, other1, options2, {
|
22 | context: _extends({}, other1.context, options2.context)
|
23 | });
|
24 |
|
25 | const wrapper = shallow(node, options);
|
26 |
|
27 | if (dive) {
|
28 | return wrapper.dive();
|
29 | }
|
30 |
|
31 | if (untilSelector) {
|
32 | return until.call(wrapper, untilSelector, options);
|
33 | }
|
34 |
|
35 | return wrapper;
|
36 | };
|
37 |
|
38 | return shallowWithContext;
|
39 | } |
\ | No newline at end of file |