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

To help you get started, we’ve selected a few react-addons-test-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 Mittal-Analytics / Screener.in / app / components / __tests__ / ratio.search-tests.js View on Github external
it('should trigger select', function() {
    var input = TestUtils.findRenderedDOMComponentWithTag(
      search, 'input'
    );
    var ratio = {name: 'Patanjali', id: 7, url: '/ramdev/'};
    api.setResponse('/api/ratios/search/?q=Patanjali',
      JSON.stringify([ratio]));
    input.value = 'Patanjali';
    TestUtils.Simulate.change(input, {target: {value: 'Patanjali'}});
    jest.runAllTimers(); // debounce;
    return search.req.then(() => {
      TestUtils.Simulate.keyDown(input, {key: "Enter", keyCode: 13, which: 13});
      expect(dummy).toBeCalledWith(ratio);
    })
  });
});
github kuy / redux-tooltip / tests / feature / multiple.js View on Github external
assert(getStyleValue(greenTip, 'visibility') === 'hidden');

      // Mouseover to red origin
      const red = firstComponent(tree, Origin.WrappedComponent, { name: 'red' }).refs.wrapper;
      TestUtils.Simulate.mouseEnter(red);

      const redTip = firstComponent(tree, Tooltip.WrappedComponent, { name: 'red' }).refs.tooltip;
      assert(getStyleValue(redTip, 'visibility') === 'visible');
      assert(redTip.innerText === 'This is a Red tooltip.');

      TestUtils.Simulate.mouseLeave(red);
      assert(getStyleValue(redTip, 'visibility') === 'hidden');

      // Mouseover to both origin
      const both = firstComponent(tree, Origin.WrappedComponent, { name: ['green', 'red'] }).refs.wrapper;
      TestUtils.Simulate.mouseEnter(both);

      assert(getStyleValue(greenTip, 'visibility') === 'visible');
      assert(greenTip.innerText === 'This is a Green tooltip.');
      assert(getStyleValue(redTip, 'visibility') === 'visible');
      assert(redTip.innerText === 'This is a Red tooltip.');

      TestUtils.Simulate.mouseLeave(both);
      assert(getStyleValue(greenTip, 'visibility') === 'hidden');
      assert(getStyleValue(redTip, 'visibility') === 'hidden');
    });
  });
github keen / explorer / test / unit / components / explorer / saved_queries / browse_queries_spec.js View on Github external
it('should call the callback if a list element is clicked', function () {
        var stub = sinon.stub();
        this.component = this.renderComponent({ clickCallback: stub });
        var firstListItem = this.component.refs.list.childNodes[0];
        TestUtils.Simulate.click(firstListItem);
        assert.isTrue(stub.calledOnce);
      });
    });
github yyssc / ssc-grid / test / GridSelectionSpec.js View on Github external
it('onBeforeSelect返回false的时候,checkbox不应该被选中', () => {
    let component = ReactTestUtils.renderIntoDocument(
       rowObj.enable,
          onSelect: () => {},
          onSelectAll: () => {}
        }}
      />
    );
    let row0checkbox = getTableCell(component, 0, 0).querySelector('input');
    let row1checkbox = getTableCell(component, 1, 0).querySelector('input');
    ReactTestUtils.Simulate.change(row0checkbox, {target: {checked: true}});
    ReactTestUtils.Simulate.change(row1checkbox, {target: {checked: true}});
    assert.equal(component.state.selectedRowsObj[0].selected, false);
    assert.equal(component.state.selectedRowsObj[1].selected, true);
    assert.equal(row0checkbox.checked, false);
    assert.equal(row1checkbox.checked, true);
  });
github t7 / react-generated-style-guide / __tests__ / test_form_textarea.js View on Github external
it('responds to change', function () {
    T.Simulate.change(textarea, {
      target: {
        value: 'new_value'
      }
    })
  })
})
github btomashvili / react-redux-firebase-boilerplate / test / test_helper.js View on Github external
$.fn.simulate = function(eventName, value) {
  if (value) {
    this.val(value);
  }
  TestUtils.Simulate[eventName](this[0]);
};
github mlaursen / react-md / src / js / Buttons / __tests__ / IconButton.js View on Github external
label="Test"
        onClick={onClick}
        onMouseOver={onMouseOver}
        onMouseLeave={onMouseLeave}
        onTouchStart={onTouchStart}
        onTouchEnd={onTouchEnd}
      />
    );

    const buttonNode = findDOMNode(button);

    TestUtils.Simulate.click(buttonNode);
    expect(onClick).toBeCalled();

    TestUtils.Simulate.mouseOver(buttonNode);
    TestUtils.Simulate.mouseLeave(buttonNode);
    expect(onMouseOver).toBeCalled();
    expect(onMouseLeave).toBeCalled();

    TestUtils.Simulate.touchStart(buttonNode, { changedTouches: [{}] });
    TestUtils.Simulate.touchEnd(buttonNode, { changedTouches: [{}] });
    expect(onTouchStart).toBeCalled();
    expect(onTouchEnd).toBeCalled();
  });
github KleeGroup / focus-components / src / components / input / checkbox / __tests__ / index.js View on Github external
beforeEach(() => {
            renderedTest = TestUtils.renderIntoDocument();
            checkbox = ReactDOM.findDOMNode(renderedTest.refs.checkbox);
            TestUtils.Simulate.change(checkbox, { target: { checked: true } });
        });
github mlaursen / react-md / src / js / Buttons / __tests__ / FlatButton.js View on Github external
onTouchStart={onTouchStart}
        onTouchEnd={onTouchEnd}
      />
    );

    const buttonNode = findDOMNode(button);

    TestUtils.Simulate.click(buttonNode);
    expect(onClick).toBeCalled();

    TestUtils.Simulate.mouseOver(buttonNode);
    TestUtils.Simulate.mouseLeave(buttonNode);
    expect(onMouseOver).toBeCalled();
    expect(onMouseLeave).toBeCalled();

    TestUtils.Simulate.touchStart(buttonNode, { changedTouches: [{}] });
    TestUtils.Simulate.touchEnd(buttonNode, { changedTouches: [{}] });
    expect(onTouchStart).toBeCalled();
    expect(onTouchEnd).toBeCalled();
  });
github nylas-mail-lives / nylas-mail / spec / components / nylas-calendar / week-view-spec.jsx View on Github external
it("goes to next week on click", () => {
    const nextBtn = this.weekView.refs.headerControls.refs.onNextAction
    expect(this.weekView.state.startMoment.unix()).toBe(NOW_BUFFER_START.unix());
    expect(this.weekView._scrollTime).toBe(NOW_WEEK_START.unix())

    ReactTestUtils.Simulate.click(nextBtn);

    expect((this.weekView.state.startMoment).unix())
      .toBe(moment(NOW_BUFFER_START).add(1, 'week').unix());

    expect(this.weekView._scrollTime)
      .toBe(moment(NOW_WEEK_START).add(1, 'week').unix());
  });