How to use the enzyme.render 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 palantir / blueprint / packages / test-commons / src / generateIsomorphicTests.ts View on Github external
function render(name: string, extraProps?: object) {
        const { children, props }: IIsomorphicTestConfig = config[name] || {};
        const finalProps = extraProps ? { ...props, ...extraProps } : props;
        // Render to static HTML, just as a server would.
        // We care merely that `render()` succeeds: it can be server-rendered.
        // Errors will fail the test and log full stack traces to the console. Nifty!
        const element = React.createElement(Components[name], finalProps, children);
        return Enzyme.render(element);
    }
github dat-land / dat-desktop / unit-tests / file-list.js View on Github external
test('file list should render a tr(s) even if directories without isEditing and size property given', t => {
  const files = [
    {
      path: '/foo'
    },
    {
      path: '/bar'
    },
    {
      path: '/baz'
    }
  ]
  const wrapper = render(
    
  )

  t.equal(wrapper.find('tr').length, files.length)

  t.end()
})
github mlaursen / react-md / docs / src / components / PhoneEmulator / __tests__ / PhoneEmulator.jsx View on Github external
it('should render only the children if mobileOnly is provided and not mobile', () => {
    const tree1 = render(
      
        
          <h2>This is some content that should appear in the phone emulator!</h2>
        
      
    );
    const tree2 = render(
      
        
          <div>Line 1</div>
          <div>Line 2</div>
        
      
    );

    expect(tree1).toMatchSnapshot();
github recharts / recharts / test / specs / shape / TriangleSpec.js View on Github external
it('Render 1 triangle in simple Triangle', () =&gt; {
    const wrapper = render(
      
        
      
    );

    expect(wrapper.find('.recharts-triangle').length).to.equal(1);
  });
github formio / react-formio / src / components / FormComponents / hidden.spec.js View on Github external
it('Check the attributes of the hidden input', function(done) {
      const element = render(
        
      ).find('input');
      expect(element.attr('value')).to.equal('');
      expect(element.attr('type')).to.equal('hidden');
      expect(element.attr('id')).to.equal('hidden');
      expect(element.attr('name')).to.equal('hidden');
      done();
    });
github formio / react-formio / src / components / FormComponents / currency.spec.js View on Github external
it('Renders with prefix and suffix', function(done) {
      component.prefix = 'Prefix';
      component.suffix = 'Suffix';
      const element = render(
        
      ).find('.input-group');
      expect(element.children().length).to.equal(3);
      expect(element.children().eq(0).hasClass('input-group-addon')).to.equal(true);
      expect(element.children().eq(0).html()).to.equal('Prefix');
      expect(element.children().eq(2).hasClass('input-group-addon')).to.equal(true);
      expect(element.children().eq(2).html()).to.equal('Suffix');
      component.prefix = '';
      component.suffix = '';
      done();
    });
github zooniverse / front-end-monorepo / packages / app-project / src / components / ProjectHeader / components / ProjectTitle / ProjectTitle.spec.js View on Github external
it('should be wrapped in an anchor with an `href`', function () {
      wrapper = render()
      expect(wrapper[0].name).to.equal('a')
      expect(wrapper.attr('href')).to.equal('/projects/foo/bar')
    })
  })
github openfun / marsha / src / frontend / components / ErrorComponent / ErrorComponent.spec.tsx View on Github external
test('ErrorComponent displays the content for 404 not found errors', () =&gt; {
  const wrapper = render();
  expect(wrapper.text()).toContain(
    'The video you are looking for could not be found',
  );
  expect(wrapper.text()).toContain(
    'This video does not exist or has not been published yet',
  );
});
github formio / react-formio / src / components / FormComponents / select.spec.js View on Github external
it('Render a basic select component', function (done) {
      const element = render(
        <select></select>
      ).children().eq(0);
      expect(element).to.have.length(1);
      expect(element.hasClass('form-group form-field-type-select form-group-select')).to.equal(true);
      expect(element.attr('id')).to.equal('form-group-select');
      done();
    });