UNPKG

1.08 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
4function shallowRecursively(wrapper, selector, _ref) {
5 let {
6 context
7 } = _ref,
8 other = _objectWithoutPropertiesLoose(_ref, ["context"]);
9
10 if (wrapper.isEmptyRender() || typeof wrapper.getElement().type === 'string') {
11 return wrapper;
12 }
13
14 let newContext = context;
15 const instance = wrapper.root().instance(); // The instance can be null with a stateless functional component and react >= 16.
16
17 if (instance && instance.getChildContext) {
18 newContext = _extends({}, context, instance.getChildContext());
19 }
20
21 const nextWrapper = wrapper.shallow(_extends({
22 context: newContext
23 }, other));
24
25 if (selector && wrapper.is(selector)) {
26 return nextWrapper;
27 }
28
29 return shallowRecursively(nextWrapper, selector, {
30 context: newContext
31 });
32}
33
34export default function until(selector, options = {}) {
35 return this.single('until', () => shallowRecursively(this, selector, options));
36}
\No newline at end of file