How to use the react-dom/test-utils.Simulate function in react-dom

To help you get started, we’ve selected a few react-dom 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 department-of-veterans-affairs / vets-website / test / edu-benefits / 1995 / config / applicantInformation.unit.spec.jsx View on Github external
// Use Array find() for nodes with 'view:' in the id, and check for ok (truthiness) instead of null since
    // not found nodes will return undefined instead of null

    // VA file number input is not visible; error is shown for empty SSN input
    const inputs = ReactTestUtils.scryRenderedDOMComponentsWithTag(form, 'input');
    expect(inputs.find(input => input.id === 'root_veteranSocialSecurityNumber')).to.be.ok;
    expect(inputs.find(input => input.id === 'root_vaFileNumber')).not.to.be.ok;

    const errors = ReactTestUtils.scryRenderedDOMComponentsWithClass(form, 'usa-input-error-message');
    expect(errors.find(input => input.id.includes('root_veteranSocialSecurityNumber'))).to.be.ok;

    // Check no-SSN box
    const noSSNBox = ReactTestUtils.scryRenderedDOMComponentsWithTag(form, 'input')
      .find(input => input.id === 'root_view:noSSN');
    ReactTestUtils.Simulate.change(noSSNBox,
      {
        target: {
          checked: true
        }
      });

    // No error is shown for empty SSN input; error is shown for empty file number input
    const newErrors = ReactTestUtils.scryRenderedDOMComponentsWithClass(form, 'usa-input-error-message');
    expect(newErrors.find(input => input.id.includes('root_veteranSocialSecurityNumber'))).not.to.be.ok;
    expect(newErrors.find(input => input.id.includes('root_vaFileNumber'))).to.be.ok;
  });
  it('should submit with no errors with all required fields filled in', () => {
github rsuite / rsuite / test / MultiCascader / DropdownSpec.js View on Github external
it('Should call onSelect callback ', done => {
    const doneOp = () => {
      done();
    };

    const instance = ReactTestUtils.renderIntoDocument(
      
    );
    const instanceDom = findDOMNode(instance.menuContainer);
    ReactTestUtils.Simulate.click(instanceDom.querySelector(itemClassName));
  });
github rsuite / rsuite / test / DateRangePicker / DateRangePickerSpec.js View on Github external
it('Should call onClean callback', done => {
    const doneOp = () => {
      done();
    };
    const instance = ReactTestUtils.renderIntoDocument(
      
    );
    const instanceDOM = findDOMNode(instance);
    ReactTestUtils.Simulate.click(instanceDOM.querySelector('.rs-picker-toggle-clean'));
  });
github AdeleD / react-paginate / __tests__ / test-clicks.js View on Github external
it('test clicks on previous and next buttons', () => {
    let elmts = ReactTestUtils.scryRenderedDOMComponentsWithTag(pagination, 'a');
    let previous = elmts[0];
    let next = elmts[elmts.length - 1];

    ReactTestUtils.Simulate.click(next);

    expect(ReactDOM.findDOMNode(pagination).querySelector(".selected a").textContent).toBe("2");

    ReactTestUtils.Simulate.click(previous);

    expect(ReactDOM.findDOMNode(pagination).querySelector(".selected a").textContent).toBe("1");
  });
github jedireza / aqua / test / client / pages / main / signup / form.js View on Github external
lab.test('it handles a submit event', (done) => {

        stub.Actions.sendRequest = function () {

            done();
        };

        const FormEl = React.createElement(Form, {});
        const form = ReactTestUtils.renderIntoDocument(FormEl);
        const formTag = ReactTestUtils.findRenderedDOMComponentWithTag(form, 'form');

        ReactTestUtils.Simulate.submit(formTag);
    });
github rsuite / rsuite / test / PanelSpec.js View on Github external
it('Should call onSelect callback', done => {
    const doneOp = eventKey => {
      if (eventKey === 12) {
        done();
      }
    };

    const instance = getDOMNode();
    ReactTestUtils.Simulate.click(instance.querySelector('.rs-panel-heading'));
  });
github redux-form / redux-form / src / __tests__ / Fields.spec.js View on Github external
customBooleanFlag
              />
              <button type="button">
            
          )
        }
      }
      const TestForm = reduxForm({ form: 'testForm' })(Form)
      const dom = TestUtils.renderIntoDocument(
        
          
        
      )

      const button = TestUtils.findRenderedDOMComponentWithTag(dom, 'button')
      TestUtils.Simulate.click(button)
      expect(renderFields).toHaveBeenCalled()
      expect(renderFields).toHaveBeenCalledTimes(2)
      const fields = renderFields.mock.calls[1][0]

      const expectField = field =&gt; {
        expect(field).toBeTruthy()
        expect(field.input).toBeTruthy()
        expect(typeof field.input.onChange).toBe('function')
        expect(typeof field.input.onBlur).toBe('function')
        expect(typeof field.input.onFocus).toBe('function')
        expect(field.meta).toBeTruthy()
        expect(field.meta.pristine).toBe(true)
        expect(field.meta.dirty).toBe(false)
        expect(field.someCustomProp).toBeFalsy()
        expect(field.anotherCustomProp).toBeFalsy()
        expect(field.customBooleanFlag).toBeFalsy()</button>
github mui-org / material-ui / test / integration / Menu.spec.js View on Github external
function simulateEvent(node, event, mock) {
  const eventFn = TestUtils.Simulate[event];
  if (!eventFn) {
    throw new TypeError(`simulateEvent: event '${event}' does not exist`);
  }
  eventFn(node, mock);
}