How to use the enzyme.ShallowWrapper function in enzyme

To help you get started, we’ve selected a few enzyme examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airbnb / lunar / packages / test-utils / src / index.tsx View on Github external
// Unwrap all wrapping and annoying HOCs
  while (getWrapperName(result) !== target) {
    const type = result.type();

    if (typeof type === 'string') {
      result = result.children();
    } else if (
      typeof type === 'object' ||
      (typeof type === 'function' && type.name === 'TempConsumer') ||
      (typeof type === 'function' && type.name === 'TempProvider')
    ) {
      const child = result.prop('children');

      if (typeof child === 'function') {
        result = new Enzyme.ShallowWrapper((child as any)(context), result, { context });

        if (options.exitOnContext) {
          return result.shallow({ context });
        }
      } else {
        result = result.shallow({ context });
      }
    } else {
      result = result.shallow({ context });
    }
  }

  // Unwrap one more time to drill into the rendered HTML (children) of the target
  if (options.render) {
    result = result.shallow({ context });
  }
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_constructor() {
        let anyWrapper: ShallowWrapper;
        anyWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper([, ]);
        shallowWrapper = new ShallowWrapper(, shallowWrapper);
        shallowWrapper = new ShallowWrapper(, undefined, { lifecycleExperimental: true });
        shallowWrapper = new ShallowWrapper(, shallowWrapper, { lifecycleExperimental: true });
    }
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_constructor() {
        let anyWrapper: ShallowWrapper;
        anyWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper([, ]);
        shallowWrapper = new ShallowWrapper(, shallowWrapper);
        shallowWrapper = new ShallowWrapper(, undefined, { lifecycleExperimental: true });
        shallowWrapper = new ShallowWrapper(, shallowWrapper, { lifecycleExperimental: true });
    }
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_constructor() {
        let anyWrapper: ShallowWrapper;
        anyWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper([, ]);
        shallowWrapper = new ShallowWrapper(, shallowWrapper);
        shallowWrapper = new ShallowWrapper(, undefined, { lifecycleExperimental: true });
        shallowWrapper = new ShallowWrapper(, shallowWrapper, { lifecycleExperimental: true });
    }
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_constructor() {
        let anyWrapper: ShallowWrapper;
        anyWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper([, ]);
        shallowWrapper = new ShallowWrapper(, shallowWrapper);
        shallowWrapper = new ShallowWrapper(, undefined, { lifecycleExperimental: true });
        shallowWrapper = new ShallowWrapper(, shallowWrapper, { lifecycleExperimental: true });
    }
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_constructor() {
        let anyWrapper: ShallowWrapper;
        anyWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper();
        shallowWrapper = new ShallowWrapper([, ]);
        shallowWrapper = new ShallowWrapper(, shallowWrapper);
        shallowWrapper = new ShallowWrapper(, undefined, { lifecycleExperimental: true });
        shallowWrapper = new ShallowWrapper(, shallowWrapper, { lifecycleExperimental: true });
    }
github DefinitelyTyped / DefinitelyTyped / types / enzyme / enzyme-tests.tsx View on Github external
function test_renderProp() {
        let shallowWrapper = new ShallowWrapper( <div>} /&gt;);
        shallowWrapper = shallowWrapper.renderProp('children')('test');
    }
</div>
github mui-org / material-ui / src / Tooltip / Tooltip.spec.js View on Github external
function getPopperChildren(wrapper) {
  return new ShallowWrapper(
    wrapper
      .find(Popper)
      .props()
      .children({ popperProps: { style: {} }, restProps: {} }),
    null,
  );
}
github freeCodeCamp / freeCodeCamp / client / epics / frame-epic.js View on Github external
    shallow: (node, options) => new ShallowWrapper(node, null, {
      ...options,
      adapter: new Adapter15()
    }),
    mount: (node, options) => new ReactWrapper(node, null, {