How to use the enzyme.describeWithDOM 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 jfairbank / react-classify / test / classify / lifecycleFunctions.js View on Github external
import React from 'react';
import { expect } from 'chai';
import { describeWithDOM, mount, shallow } from 'enzyme';
import ReactDOM from 'react-dom';
import sinon from 'sinon';
import classify from '../../src/classify';

describeWithDOM('lifecycleFunctions', () => {
  it('receives props', () => {
    const content = 'hello';
    const [Text, WrappedText] = createTextComponent();

    shallow();

    expect(Text).to.have.been
      .calledOnce.and
      .calledWith({ content });
  });

  it('uses componentWillMount', () => {
    testNoExtraArgs('componentWillMount', { render: shallow });
  });

  it('uses componentDidMount', () => {
github carteb / react-pure-ui / test / unit / components / playground / renderControls.js View on Github external
});

  it('should call setComponentProperties on control input changes', () => {
    const properties = {
      age: ,
    };

    const callback = spy();
    const result = renderControls(properties, { age: 22 }, callback);
    const controls = shallow(result[0]);
    controls.find('input').simulate('change', { target: { value: 32 } });
    expect(callback).to.have.been.calledOnce;
    expect(callback).to.have.been.calledWith({ age: 32 });
  });

  describeWithDOM('nested control', () => {
    it('should call setComponentProperties on input changes', () => {
      const properties = {
        foo: {
          bar: ,
        },
      };

      const callback = spy();
      const result = renderControls(properties, { foo: { bar: 22 } }, callback);
      const controls = mount(result[0]);
      controls.find('input').simulate('change', { target: { value: 32 } });
      expect(callback).to.have.been.calledOnce;
      expect(callback).to.have.been.calledWith({ foo: { bar: 32 } });
    });
  });
});
github SpencerCDixon / react-testing-starter-kit / test / containers / CommentContainer.spec.js View on Github external
describe('(Component) CommentContainer', () => {
  it('renders as a div', () => {
    const wrapper = shallow();
    const spy = sinon.spy();

    expect(wrapper.type()).to.eql('div');
  });

  describeWithDOM('Lifecycle methods', () => {
    it('calls component did mount', () => {
      spyLifecycle(CommentContainer);
      mount();

      expect(
        CommentContainer.prototype.componentDidMount.calledOnce
      ).to.be.true;
    });
  });
});