How to use the react-addons-test-utils.SimulateNative 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 ikr / react-star-rating-input / tests / StarRatingInput.spec.js View on Github external
it('include signalling no prospective value on mouse leave for a star', function () {
            // TestUtils.Simulate.mouseLeave(component.refs.s2); doesn't work
            // -- that's a known issue https://github.com/facebook/react/issues/1297
            // therefore, here's a (hopefully) temporary workaround
            //
            TestUtils.SimulateNative.mouseOut(component.refs.s2);

            assert.strictEqual(spy.callCount, 0);
            assert.strictEqual(component.state.prospectiveValue, 0);
        });
github ikr / react-star-rating-input / tests / StarRatingInput.spec.js View on Github external
it('include signaling new prespective value on mouse hover for a star', function () {
            // TestUtils.Simulate.mouseEnter(component.refs.s4); doesn't work
            // -- that's a known issue https://github.com/facebook/react/issues/1297
            // therefore, here's a (hopefully) temporary workaround
            //
            TestUtils.SimulateNative.mouseOver(component.refs.s4);

            assert.strictEqual(spy.callCount, 0);
            assert.strictEqual(component.state.prospectiveValue, 4);
        });
github gpbl / react-day-picker / test / DayPicker.js View on Github external
const handlerCallback = [
      sinon.match((e) => {
        return e instanceof SyntheticEvent && e.target !== null;
      }, "e"),
      sinon.match(isFirstDay, "d"),
      sinon.match((mods) => {
        return mods instanceof Array && mods[0] === "firstDay";
      }, "modifiers")
    ];

    TestUtils.Simulate.click(dayEl);
    expect(handleClick).to.have.been.calledWith(...handlerCallback);

    // See https://github.com/facebook/react/issues/1297 for testing enter/leave
    // events
    TestUtils.SimulateNative.mouseOver(dayEl);
    expect(handleMouseEnter).to.have.been.calledWith(...handlerCallback);

    TestUtils.SimulateNative.mouseOut(dayEl);
    expect(handleMouseLeave).to.have.been.calledWith(...handlerCallback);

    TestUtils.Simulate.touchTap(dayEl);
    expect(handleTouchTap).to.have.been.called;

  });
github AndrewKeig / react-speech / test / button.js View on Github external
it('should update hover state when no longer hovering', () => {
      let input = component;
      TestUtils.SimulateNative.mouseOver(input);
      expect(button.state.hover).to.equal(true);
      TestUtils.SimulateNative.mouseOut(input);

      expect(button.state.hover).to.equal(false);
    });
  });
github AndrewKeig / react-speech / test / button.js View on Github external
it('should update hover state', () => {
      let input = component;
      TestUtils.SimulateNative.mouseOver(input);
      expect(button.state.hover).to.equal(true);
    });
github AndrewKeig / react-speech / test / speech.js View on Github external
before(() =>{
      speech = TestUtils.renderIntoDocument();
      component = TestUtils.scryRenderedDOMComponentsWithTag(speech, 'button');
      let input1 = component[0];
      TestUtils.SimulateNative.click(input1);
      let input2 = component[1];
      TestUtils.SimulateNative.click(input2);
    });
github moroshko / react-autosuggest / test / Autosuggest.js View on Github external
import proxyquire from 'proxyquire';
import chai, { expect } from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import SyntheticEvent from 'react/lib/SyntheticEvent';

chai.use(sinonChai);

const Autosuggest = proxyquire('../src/Autosuggest', { debounce: fn => fn });
const Simulate = TestUtils.Simulate;
const SimulateNative = TestUtils.SimulateNative;
const suburbObjects = [
  { suburb: 'Cheltenham', postcode: '3192' },
  { suburb: 'Mill Park', postcode: '3083' },
  { suburb: 'Mordialloc', postcode: '3195' },
  { suburb: 'Nunawading', postcode: '3131' }
];
const stringSuburbs = suburbObjects.map(suburbObj => suburbObj.suburb);
const reactAttributesRegex = / data-react[-\w]+="[^"]+"/g;
let autosuggest, input, suggestions;
const onSuggestionSelected = sinon.spy();
const onSuggestionFocused = sinon.spy();
const onSuggestionUnfocused = sinon.spy();
const onChange = sinon.spy();
const onBlur = sinon.spy();
const getSuburbs = sinon.spy(getSuburbStrings);
github gpbl / react-day-picker / test / DayPicker.js View on Github external
onDayMouseEnter={handleMouseEnter}
        onDayMouseLeave={handleMouseLeave}
        onDayTouchTap={handleTouchTap} />
    );

    const daysEl = TestUtils.scryRenderedDOMComponentsWithClass(dayPickerEl,
      "DayPicker-Day");
    const dayEl = daysEl[0];

    TestUtils.Simulate.click(dayEl);
    expect(handleClick).to.not.have.been.called;

    TestUtils.SimulateNative.mouseOver(dayEl);
    expect(handleMouseEnter).to.not.have.been.called;

    TestUtils.SimulateNative.mouseOut(dayEl);
    expect(handleMouseLeave).to.not.have.been.called;

    TestUtils.Simulate.touchTap(dayEl);
    expect(handleTouchTap).to.not.have.been.called;

  });
github AndrewKeig / react-speech / test / speech.js View on Github external
before(() =>{
      speech = TestUtils.renderIntoDocument();
      component = TestUtils.scryRenderedDOMComponentsWithTag(speech, 'button');
      let input1 = component[0];
      TestUtils.SimulateNative.click(input1);
    });