How to use the enzyme-adapter-utils.assertDomAvailable function in enzyme-adapter-utils

To help you get started, we’ve selected a few enzyme-adapter-utils 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 drcmda / react-contextual / tests / jest.react.16.adapter.js View on Github external
createMountRenderer(options) {
    assertDomAvailable('mount')
    const domNode = options.attachTo || global.document.createElement('div')
    let instance = null
    return {
      render(el, context, callback) {
        if (instance === null) {
          const ReactWrapperComponent = createMountWrapper(el, options)
          const wrappedEl = React.createElement(ReactWrapperComponent, {
            Component: el.type,
            props: el.props,
            context,
          })
          instance = ReactDOM.render(wrappedEl, domNode)
          if (typeof callback === 'function') {
            callback()
          }
        } else {
github unsplash / react-progressive-enhancement / tests / ReactSixteenAdapter.js View on Github external
createMountRenderer(options) {
    assertDomAvailable('mount');
    const domNode = options.attachTo || global.document.createElement('div');
    let instance = null;
    return {
      render(el, context, callback) {
        if (instance === null) {
          const ReactWrapperComponent = createMountWrapper(el, options);
          const wrappedEl = React.createElement(ReactWrapperComponent, {
            Component: el.type,
            props: el.props,
            context,
          });
          instance = ReactDOM.render(wrappedEl, domNode);
          if (typeof callback === 'function') {
            callback();
          }
        } else {
github airbnb / enzyme / packages / enzyme-adapter-react-15 / src / ReactFifteenAdapter.js View on Github external
createMountRenderer(options) {
    assertDomAvailable('mount');
    const domNode = options.attachTo || global.document.createElement('div');
    let instance = null;
    const adapter = this;
    return {
      render(el, context, callback) {
        if (instance === null) {
          const { type, props, ref } = el;
          const wrapperProps = {
            Component: type,
            wrappingComponentProps: options.wrappingComponentProps,
            props,
            context,
            ...(ref && { refProp: ref }),
          };
          const ReactWrapperComponent = createMountWrapper(el, { ...options, adapter });
          const wrappedEl = React.createElement(ReactWrapperComponent, wrapperProps);
github airbnb / enzyme / packages / enzyme-adapter-react-16 / src / ReactSixteenAdapter.js View on Github external
createMountRenderer(options) {
    assertDomAvailable('mount');
    const { attachTo, hydrateIn } = options;
    const domNode = hydrateIn || attachTo || global.document.createElement('div');
    let instance = null;
    return {
      render(el, context, callback) {
        if (instance === null) {
          const { type, props, ref } = el;
          const wrapperProps = {
            Component: type,
            props,
            context,
            ...(ref && { ref }),
          };
          const ReactWrapperComponent = createMountWrapper(el, options);
          const wrappedEl = React.createElement(ReactWrapperComponent, wrapperProps);
          instance = hydrateIn
github airbnb / enzyme / packages / enzyme-adapter-react-16.3 / src / ReactSixteenThreeAdapter.js View on Github external
createMountRenderer(options) {
    assertDomAvailable('mount');
    const { attachTo, hydrateIn, wrappingComponentProps } = options;
    const domNode = hydrateIn || attachTo || global.document.createElement('div');
    let instance = null;
    const adapter = this;
    return {
      render(el, context, callback) {
        if (instance === null) {
          const { type, props, ref } = el;
          const wrapperProps = {
            Component: type,
            props,
            wrappingComponentProps,
            context,
            ...(ref && { refProp: ref }),
          };
          const ReactWrapperComponent = createMountWrapper(el, { ...options, adapter });
github airbnb / enzyme / packages / enzyme-adapter-react-13 / src / ReactThirteenAdapter.js View on Github external
createMountRenderer(options) {
    assertDomAvailable('mount');
    const domNode = options.attachTo || global.document.createElement('div');
    let instance = null;
    return {
      render(el, context, callback) {
        if (instance === null) {
          const { ref, type, props } = el;
          const wrapperProps = {
            Component: type,
            props,
            context,
            ...(ref && { ref }),
          };
          const ReactWrapperComponent = createMountWrapper(el, options);
          const wrappedEl = React.createElement(ReactWrapperComponent, wrapperProps);
          instance = React.render(wrappedEl, domNode);
          if (typeof callback === 'function') {
github aweary / enzyme-adapter-preact / src / PreactAdapter.js View on Github external
createMountRenderer(options) {
    assertDomAvailable('mount');
    const domNode = options.attachTo || global.document.createElement('div');
    let instance = null;
    return {
      render(el, context, callback) {
        if (instance === null) {
          const PreactWrapperComponent = createMountWrapper(el, options);
          const wrappedEl = Preact.h(PreactWrapperComponent, {
            Component: el.type,
            props: el.props,
            context,
          });
          instance = Preact.render(wrappedEl, domNode);
          if (typeof callback === 'function') {
            callback();
          }
        } else {
github airbnb / enzyme / packages / enzyme-adapter-react-15 / src / ReactFifteenAdapter.js View on Github external
createMountRenderer(options) {
    assertDomAvailable('mount');
    const domNode = options.attachTo || global.document.createElement('div');
    let instance = null;
    return {
      render(el, context, callback) {
        if (instance === null) {
          const { type, props, ref } = el;
          const wrapperProps = {
            Component: type,
            props,
            context,
            ...(ref && { ref }),
          };
          const ReactWrapperComponent = createMountWrapper(el, options);
          const wrappedEl = React.createElement(ReactWrapperComponent, wrapperProps);
          instance = ReactDOM.render(wrappedEl, domNode);
          if (typeof callback === 'function') {