@mui/internal-test-utils 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/.tsbuildinfo +1 -1
- package/build/createRenderer.d.ts +3 -3
- package/build/createRenderer.d.ts.map +1 -1
- package/build/describeConformance.d.ts +10 -9
- package/build/describeConformance.d.ts.map +1 -1
- package/build/describeConformance.js +46 -77
- package/build/describeConformance.js.map +1 -1
- package/build/flushMicrotasks.js +1 -1
- package/build/flushMicrotasks.js.map +1 -1
- package/build/index.d.ts +0 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -6
- package/build/index.js.map +1 -1
- package/build/init.js +0 -6
- package/build/init.js.map +1 -1
- package/build/mochaHooks.test.js +1 -0
- package/build/mochaHooks.test.js.map +1 -1
- package/package.json +3 -6
- package/src/createRenderer.tsx +3 -3
- package/src/describeConformance.tsx +66 -94
- package/src/flushMicrotasks.ts +1 -1
- package/src/index.ts +0 -2
- package/src/init.js +0 -4
- package/src/mochaHooks.test.js +1 -0
- package/tsconfig.json +1 -0
- package/build/createMount.d.ts +0 -9
- package/build/createMount.d.ts.map +0 -1
- package/build/createMount.js +0 -120
- package/build/createMount.js.map +0 -1
- package/build/findOutermostIntrinsic.d.ts +0 -14
- package/build/findOutermostIntrinsic.d.ts.map +0 -1
- package/build/findOutermostIntrinsic.js +0 -22
- package/build/findOutermostIntrinsic.js.map +0 -1
- package/build/findOutermostIntrinsic.test.d.ts +0 -2
- package/build/findOutermostIntrinsic.test.d.ts.map +0 -1
- package/build/findOutermostIntrinsic.test.js +0 -70
- package/build/findOutermostIntrinsic.test.js.map +0 -1
- package/build/until.d.ts +0 -2
- package/build/until.d.ts.map +0 -1
- package/build/until.js +0 -26
- package/build/until.js.map +0 -1
- package/build/until.test.d.ts +0 -2
- package/build/until.test.d.ts.map +0 -1
- package/build/until.test.js +0 -118
- package/build/until.test.js.map +0 -1
- package/src/createMount.tsx +0 -136
- package/src/findOutermostIntrinsic.test.js +0 -68
- package/src/findOutermostIntrinsic.ts +0 -19
- package/src/until.js +0 -28
- package/src/until.test.js +0 -120
package/src/until.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
function shallowRecursively(wrapper, selector, { context, ...other }) {
|
|
2
|
-
if (wrapper.isEmptyRender() || typeof wrapper.getElement().type === 'string') {
|
|
3
|
-
return wrapper;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
let newContext = context;
|
|
7
|
-
|
|
8
|
-
const instance = wrapper.root().instance();
|
|
9
|
-
// The instance can be null with a stateless functional component and react >= 16.
|
|
10
|
-
if (instance && instance.getChildContext) {
|
|
11
|
-
newContext = {
|
|
12
|
-
...context,
|
|
13
|
-
...instance.getChildContext(),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const nextWrapper = wrapper.shallow({ context: newContext, ...other });
|
|
18
|
-
|
|
19
|
-
if (selector && wrapper.is(selector)) {
|
|
20
|
-
return nextWrapper;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return shallowRecursively(nextWrapper, selector, { context: newContext });
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default function until(selector, options = {}) {
|
|
27
|
-
return this.single('until', () => shallowRecursively(this, selector, options));
|
|
28
|
-
}
|
package/src/until.test.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { shallow } from 'enzyme';
|
|
5
|
-
import until from './until';
|
|
6
|
-
|
|
7
|
-
function Div() {
|
|
8
|
-
return <div />;
|
|
9
|
-
}
|
|
10
|
-
const hoc = (Component) =>
|
|
11
|
-
function Wrapper() {
|
|
12
|
-
return <Component />;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('until', () => {
|
|
16
|
-
it('shallow renders the current wrapper one level deep', () => {
|
|
17
|
-
const EnhancedDiv = hoc(Div);
|
|
18
|
-
const wrapper = until.call(shallow(<EnhancedDiv />), 'Div');
|
|
19
|
-
expect(wrapper.contains(<div />)).to.equal(true);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('shallow renders the current wrapper several levels deep', () => {
|
|
23
|
-
const EnhancedDiv = hoc(hoc(hoc(Div)));
|
|
24
|
-
const wrapper = until.call(shallow(<EnhancedDiv />), 'Div');
|
|
25
|
-
expect(wrapper.contains(<div />)).to.equal(true);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('stops shallow rendering when the wrapper is empty', () => {
|
|
29
|
-
const nullHoc = () => () => null;
|
|
30
|
-
const EnhancedDiv = nullHoc();
|
|
31
|
-
const wrapper = until.call(shallow(<EnhancedDiv />), 'Div');
|
|
32
|
-
expect(wrapper.html()).to.equal(null);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('shallow renders as much as possible when no selector is provided', () => {
|
|
36
|
-
const EnhancedDiv = hoc(hoc(Div));
|
|
37
|
-
const wrapper = until.call(shallow(<EnhancedDiv />));
|
|
38
|
-
expect(wrapper.contains(<div />)).to.equal(true);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('shallow renders the current wrapper even if the selector never matches', () => {
|
|
42
|
-
const EnhancedDiv = hoc(Div);
|
|
43
|
-
const wrapper = until.call(shallow(<EnhancedDiv />), 'NotDiv');
|
|
44
|
-
expect(wrapper.contains(<div />)).to.equal(true);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('stops shallow rendering when it encounters a HTML element', () => {
|
|
48
|
-
const wrapper = until.call(
|
|
49
|
-
shallow(
|
|
50
|
-
<div>
|
|
51
|
-
<Div />
|
|
52
|
-
</div>,
|
|
53
|
-
),
|
|
54
|
-
'Div',
|
|
55
|
-
);
|
|
56
|
-
expect(
|
|
57
|
-
wrapper.contains(
|
|
58
|
-
<div>
|
|
59
|
-
<Div />
|
|
60
|
-
</div>,
|
|
61
|
-
),
|
|
62
|
-
).to.equal(true);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('throws when until called on an empty wrapper', () => {
|
|
66
|
-
expect(() => {
|
|
67
|
-
until.call(shallow(<Div />).find('Foo'), 'div');
|
|
68
|
-
}).to.throw(Error);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('shallow renders non-root wrappers', () => {
|
|
72
|
-
function Container() {
|
|
73
|
-
return (
|
|
74
|
-
<div>
|
|
75
|
-
<Div />
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
const wrapper = until.call(shallow(<Container />).find(Div));
|
|
80
|
-
expect(wrapper.contains(<div />)).to.equal(true);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// eslint-disable-next-line react/prefer-stateless-function
|
|
84
|
-
class Foo extends React.Component {
|
|
85
|
-
render() {
|
|
86
|
-
return <Div />;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
Foo.contextTypes = {
|
|
91
|
-
quux: PropTypes.bool.isRequired,
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
it('context propagation passes down context from the root component', () => {
|
|
95
|
-
const EnhancedFoo = hoc(Foo);
|
|
96
|
-
const options = { context: { quux: true } };
|
|
97
|
-
const wrapper = until.call(shallow(<EnhancedFoo />, options), 'Foo', options);
|
|
98
|
-
expect(wrapper.context('quux')).to.equal(true);
|
|
99
|
-
expect(wrapper.contains(<Div />)).to.equal(true);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
class Bar extends React.Component {
|
|
103
|
-
static childContextTypes = { quux: PropTypes.bool };
|
|
104
|
-
|
|
105
|
-
getChildContext() {
|
|
106
|
-
return { quux: true };
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
render() {
|
|
110
|
-
return <Foo />;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
it('context propagation passes down context from an intermediary component', () => {
|
|
115
|
-
const EnhancedBar = hoc(Bar);
|
|
116
|
-
const wrapper = until.call(shallow(<EnhancedBar />), 'Foo');
|
|
117
|
-
expect(wrapper.context('quux')).to.equal(true);
|
|
118
|
-
expect(wrapper.contains(<Div />)).to.equal(true);
|
|
119
|
-
});
|
|
120
|
-
});
|