How to use the react-addons-test-utils.Simulate.change 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 NiGhTTraX / react-test-buffet / tests / acceptance / adding-todos.spec.js View on Github external
function addTodo($component, todo) {
  const node = $component.find('.new-todo')[0];

  // TODO: this exposes too much of the internals; figure out a way to write
  // tests without knowing all of this
  Simulate.change(node, { target: { value: todo } });
  Simulate.keyDown(node, {
    keyCode: ENTER
  });
}
github react-component / select / tests / tags.spec.js View on Github external
it('should allow user input as tags', (done) => {
    if (navigator.userAgent.indexOf(' Chrome') === -1) {
      done();
      return;
    }

    const node = instance.getInputDOMNode();
    node.focus();
    node.value = 'A';
    Simulate.change(node);
    setTimeout(() => {
      Simulate.keyDown(node, {
        keyCode: KeyCode.ENTER,
      });
      setTimeout(() => {
        expect(instance.state.value.map(v => v.key)).toContain('A');
        done();
      }, 100);
    }, 100);
  });
});
github ianmcnally / react-currency-masked-input / test / react-currency-masked-input_spec.js View on Github external
it('updates `value` when the input`s value changes', () => {
        const input = findRenderedDOMComponentWithTag(inputWrapper, 'input')

        Simulate.change(input, { target : { value : '102' } })

        expect(inputWrapper.refs.input.value).toEqual('1.02')
      })
github systemaccounting / mxfactorial / test / app / components / Transaction / TransactionSection.spec.js View on Github external
instance.context.router = { push };
    const requestBtnComponent = findRenderedComponentWithType(instance, RequestBtn);
    const requestBtn = findRenderedDOMComponentWithClass(requestBtnComponent, 'btn__request');
    Simulate.click(requestBtn);

    const requestPopup = findRenderedComponentWithType(instance, RequestPopup);
    const expirationInput = findRenderedDOMComponentWithClass(requestPopup, 'expiration');
    expirationInput.value = '5';
    Simulate.change(expirationInput);
    const btnOk = findRenderedDOMComponentWithClass(requestPopup, 'btn__ok');
    Simulate.click(btnOk);

    props.updateError.should.be.calledWith('Password Required');
    const passwordInput = findRenderedDOMComponentWithClass(requestPopup, 'password');
    passwordInput.value = 'secret';
    Simulate.change(passwordInput);

    Simulate.click(btnOk);
    props.postTransaction.should.be.calledWith({
      db_author: 'Sandy',
      cr_author: 'Mindy',
      cr_latlng: '0,0',
      expiration_time: 5,
      transaction_item: [{
        key: 0,
        name: 'item1',
        quantity: 1,
        value: 25,
        db_account: 'Sandy',
        cr_account: 'Mindy'
      }],
      username: 'JonSnow',
github systemaccounting / mxfactorial / test / app / components / Transaction / TransactionSection.spec.js View on Github external
props.postTransaction = stub();
    props.postTransaction.returns({
      then: (f) => (f({}))
    });
    const push = spy();

    instance = renderIntoDocument();
    instance.context.router = { push };
    const requestBtnComponent = findRenderedComponentWithType(instance, RequestBtn);
    const requestBtn = findRenderedDOMComponentWithClass(requestBtnComponent, 'btn__request');
    Simulate.click(requestBtn);

    const requestPopup = findRenderedComponentWithType(instance, RequestPopup);
    const expirationInput = findRenderedDOMComponentWithClass(requestPopup, 'expiration');
    expirationInput.value = '5';
    Simulate.change(expirationInput);
    const btnOk = findRenderedDOMComponentWithClass(requestPopup, 'btn__ok');
    Simulate.click(btnOk);

    props.updateError.should.be.calledWith('Password Required');
    const passwordInput = findRenderedDOMComponentWithClass(requestPopup, 'password');
    passwordInput.value = 'secret';
    Simulate.change(passwordInput);

    Simulate.click(btnOk);
    props.postTransaction.should.be.calledWith({
      db_author: 'Sandy',
      cr_author: 'Mindy',
      cr_latlng: '0,0',
      expiration_time: 5,
      transaction_item: [{
        key: 0,
github auth0 / lock-passwordless / test / acceptance_test_utils.js View on Github external
export function fillInput(lock, name, value) {
  Simulate.change(qInput(lock, name, true), {target: {value: value}});
}
github systemaccounting / mxfactorial / test / app / components / AccountProfileSetting / AccountProfileConfirm.spec.js View on Github external
instance = renderIntoDocument(
      
    );

    const push = spy();
    instance.context.router = { push };

    const errorMessage = findRenderedDOMComponentWithClass(instance, 'error-message');

    const btnOk = findRenderedDOMComponentWithClass(instance, 'btn__ok');
    const passwordInput = findRenderedDOMComponentWithTag(instance, 'input');
    Simulate.click(btnOk);
    errorMessage.textContent.should.equal('Password required');

    passwordInput.value = 'abcd1234';
    Simulate.change(passwordInput);
    Simulate.click(btnOk);

    push.should.be.calledWith('/AccountProfile/Success');
  });
github mlaursen / react-md / src / js / SelectionControls / __tests__ / ControlContainer.js View on Github external
const onChange = jest.fn((checked) => {
      props = Object.assign({}, props, { checked });
    });

    let control = renderIntoDocument();

    let input = findRenderedDOMComponentWithTag(control, 'input');
    Simulate.change(input, { target: { checked: true } });

    control = renderIntoDocument();
    input = findRenderedDOMComponentWithTag(control, 'input');
    expect(input.checked).toBe(true);
    expect(onChange.mock.calls.length).toBe(1);

    Simulate.change(input, { target: { checked: false } });

    control = renderIntoDocument();
    input = findRenderedDOMComponentWithTag(control, 'input');
    expect(input.checked).toBe(false);
    expect(onChange.mock.calls.length).toBe(2);
  });
});
github react-component / select / tests / optionFilterProp.spec.js View on Github external
<option label="二" value="2">2</option>
        <option label="十一" value="11">11</option>
      , div);
    ReactDOM.findDOMNode(select.refs.selection).focus();
    Simulate.click(ReactDOM.findDOMNode(select.refs.selection));
    select.getInputDOMNode().value = 1;
    Simulate.change(select.getInputDOMNode());
    expect($(select.getPopupDOMNode()).find('.rc-select-dropdown-menu-item').length).toBe(0);
    select.getInputDOMNode().value = 2;
    Simulate.change(select.getInputDOMNode());
    expect($(select.getPopupDOMNode()).find('.rc-select-dropdown-menu-item').length).toBe(0);
    select.getInputDOMNode().value = '一';
    Simulate.change(select.getInputDOMNode());
    expect($(select.getPopupDOMNode()).find('.rc-select-dropdown-menu-item').length).toBe(2);
    select.getInputDOMNode().value = '二';
    Simulate.change(select.getInputDOMNode());
    expect($(select.getPopupDOMNode()).find('.rc-select-dropdown-menu-item').length).toBe(1);
  });
});
github salesforce-ux / design-system / ui / components / menus / index.react.spec.jsx View on Github external
it(`filters its items`, () => {
        Simulate.change(node, {target: {value: 'o'}});
        expect(getItems()).length.to.be(2);
      });
    });