How to use enzyme-adapter-react-helper - 7 common examples

To help you get started, we’ve selected a few enzyme-adapter-react-helper 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 / enzyme / packages / enzyme-adapter-react-15.4 / src / ReactFifteenFourAdapter.js View on Github external
invokeSetStateCallback(instance, callback) {
    // React in >= 15.4, and < 16 pass undefined to a setState callback
    const invoke = ifReact(
      '^15.4',
      () => { callback.call(instance, undefined); },
      () => { super.invokeSetStateCallback(instance, callback); },
    );
    invoke();
  }
github airbnb / enzyme / packages / enzyme-adapter-react-15.4 / src / ReactFifteenFourAdapter.js View on Github external
invokeSetStateCallback(instance, callback) {
    // React in >= 15.4, and < 16 pass undefined to a setState callback
    const invoke = ifReact(
      '^15.4',
      () => { callback.call(instance, undefined); },
      () => { super.invokeSetStateCallback(instance, callback); },
    );
    invoke();
  }
}
github airbnb / prop-types / test / ref.jsx View on Github external
const itIfReact = (version, ...args) => ifReact(version, () => it(...args), () => it.skip(...args));
github airbnb / prop-types / test / helpers / getComponentName.js View on Github external
const itIfReact = (version, ...args) => ifReact(version, () => it(...args), () => it.skip(...args));
github tajo / react-portal / __tests__ / PortalWithState.js View on Github external
ReactDOM.unmountComponentAtNode(document.getElementById('root'));
  document.body.innerHTML = '';
});

ifReact('>= 16', test, test.skip)('should not mount portal by default', () => {
  ReactDOM.render(
    {({ portal }) => portal('Foo')},
    document.getElementById('root')
  );
  expect(document.body.firstChild.outerHTML).toBe('<div id="root"></div>');
  expect(document.body.lastChild.outerHTML).toBe(
    document.body.lastChild.outerHTML
  );
});

ifReact('&lt; 16', test, test.skip)('should not mount portal by default', () =&gt; {
  ReactDOM.render(
    {({ portal }) =&gt; portal('Foo')},
    document.getElementById('root')
  );
  expect(document.body.firstChild.outerHTML).toBe(
    '<div id="root"></div>'
  );
  expect(document.body.lastChild.outerHTML).toBe(
    document.body.lastChild.outerHTML
  );
});

ifReact('&gt;= 16', test, test.skip)(
  'should mount portal by default with defaultOpen',
  () =&gt; {
    ReactDOM.render(
github tajo / react-portal / __tests__ / PortalWithState.js View on Github external
import React from 'react';
import ReactDOM from 'react-dom';
import ifReact from 'enzyme-adapter-react-helper/build/ifReact';
import PortalWithState from '../src/PortalWithState';

beforeEach(() =&gt; {
  document.body.innerHTML = '<div id="root"></div>';
});

afterEach(() =&gt; {
  ReactDOM.unmountComponentAtNode(document.getElementById('root'));
  document.body.innerHTML = '';
});

ifReact('&gt;= 16', test, test.skip)('should not mount portal by default', () =&gt; {
  ReactDOM.render(
    {({ portal }) =&gt; portal('Foo')},
    document.getElementById('root')
  );
  expect(document.body.firstChild.outerHTML).toBe('<div id="root"></div>');
  expect(document.body.lastChild.outerHTML).toBe(
    document.body.lastChild.outerHTML
  );
});

ifReact('&lt; 16', test, test.skip)('should not mount portal by default', () =&gt; {
  ReactDOM.render(
    {({ portal }) =&gt; portal('Foo')},
    document.getElementById('root')
  );
  expect(document.body.firstChild.outerHTML).toBe(
github tajo / react-portal / examples / index.js View on Github external
this.setState(prevState =&gt; ({
              isPortalTwoActive: !prevState.isPortalTwoActive
            }))
          }
        &gt;
          Toggle
        
        {this.state.isPortalTwoActive &amp;&amp; (
          
            <p>This thing was portaled with custom node!</p>
          
        )}

        <h2>PortalWithState</h2>
        
          {ifReact(
            '&lt; 16.2',
            ({ openPortal, closePortal, isOpen, portal }) =&gt; (
              <div>
                <button>
                  Open Portal {isOpen &amp;&amp; '(this counts as an outside click)'}
                </button>
                {portal(
                  <p>
                    This is more advanced Portal. It handles its own state.{' '}
                    <button>Close me!</button>, hit ESC or
                    click outside of me.
                  </p>
                )}
              </div>
            ),
            ({ openPortal, closePortal, isOpen, portal }) =&gt; (

enzyme-adapter-react-helper

JavaScript Testing utilities for React

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis

Popular enzyme-adapter-react-helper functions