How to use the react-addons-test-utils.Simulate.click 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 youzan / zent / packages / zent-sweetalert / __tests__ / spec.js View on Github external
expect(called).toBe(true);
  unmount();

  // callback returns Promise(resolve)
  called = false;
  let cbPromise = () => {
    return new Promise((resolve) => {
      called = true;
      setTimeout(resolve, 2000);
    });
  };
  close = modal({
    [key]: cbPromise
  });
  expect(called).toBe(false);
  Simulate.click(document.querySelector(btnSelector));
  jest.runOnlyPendingTimers();
  expect(called).toBe(true);
  unmount();

  // callback with args that returns Promise
  called = false;
  const cbPromiseWithArg = (closeFn) => {
    expect(document.querySelector(btnSelector).classList.contains('zent-btn-loading')).toBe(false);

    return new Promise((resolve) => {
      setTimeout(() => {
        called = true;
        closeFn(); // close manually
        expect(document.querySelector(btnSelector).classList.contains('zent-btn-loading')).toBe(true);
        resolve();
      }, 2000);
github salesforce-ux / design-system / ui / components / tooltips / index.react.spec.jsx View on Github external
beforeEach(() => {
        control = scryRenderedDOMComponentsWithClass(cmp, 'clicky-mcduck')[0];
        Simulate.click(control, {});
        popover = document.querySelectorAll('.popover')[1] // it clones the original;
        wrapper = document.querySelectorAll('.popover-wrapper')[0];
      });
      it(`has the appropriate nubbin classname`, () => {
github react-component / table / tests / basic.spec.js View on Github external
it('should use rowClick to expand', () => {
    const clickRow = node.find('tbody tr:first');
    Simulate.click(clickRow[0]);
    expect(clickRow.next().text()).to.be('123');
  });
});
github systemaccounting / mxfactorial / test / app / components / AccountProfileSetting / AccountProfileConfirm.spec.js View on Github external
it('should handle Cancel', () => {
    instance = renderIntoDocument(
      
    );

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

    const btnCancel = findRenderedDOMComponentWithClass(instance, 'btn__cancel');

    Simulate.click(btnCancel);

    push.should.be.calledWith('/AccountProfile');
  });
});
github react-component / select / tests / optionFilterProp.spec.js View on Github external
it('can set optionFilterProp', () => {
    const select = ReactDOM.render(
      <select style="{{">
        <option label="一" value="1">1</option>
        <option label="二" value="2">2</option>
        <option label="十一" value="11">11</option>
      </select>, 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 auth0 / lock-passwordless / test / acceptance_test_utils.js View on Github external
export function closeLock(lock) {
  const node = q(lock, ".auth0-lock-close-button");
  if (!node) {
    throw new Error("Unable to close the Lock: couldn't find the close button");
  }

  Simulate.click(node, {});

  if (isOpened(lock)) {
    throw new Error("Unable to close the Lock: clicking the close button didn't work");
  }
}
github systemaccounting / mxfactorial / test / app / components / Transaction / TransactionSection.spec.js View on Github external
props.updateError = spy();

    const push = spy();

    instance = renderIntoDocument();
    scryRenderedComponentsWithType(instance, TransactionPopup).length.should.equal(0);
    instance.context.router = { push };
    const transactBtnComponent = findRenderedComponentWithType(instance, TransactBtn);
    const transactBtn = findRenderedDOMComponentWithClass(transactBtnComponent, 'btn__transact');
    Simulate.click(transactBtn);

    const transactionPopup = findRenderedComponentWithType(instance, TransactionPopup);
    const okBtn = findRenderedDOMComponentWithClass(transactionPopup, 'btn__ok');
    const passwordInput = findRenderedDOMComponentWithClass(transactionPopup, 'password');
    const expirationInput = findRenderedDOMComponentWithClass(transactionPopup, 'expiration');
    Simulate.click(okBtn);

    props.updateError.should.be.calledWith('Password Required');
    expirationInput.value='1';
    ReactTestUtils.Simulate.change(expirationInput);
    passwordInput.value = 'secret';
    Simulate.change(passwordInput);
    Simulate.click(okBtn);

    props.postTransaction.should.be.calledWith({
      db_author: 'Sandy',
      cr_author: '',
      db_latlng: '0,0',
      expiration_time: 1,
      transaction_item: [{
        key: 0,
        name: 'item1',
github nylas-mail-lives / nylas-mail / spec / components / editable-list-spec.jsx View on Github external
it('calls onSelectItem', () => {
      const onSelectItem = jasmine.createSpy('onSelectItem');
      const list = makeList(['1', '2'], {onSelectItem});
      const item = scryRenderedDOMComponentsWithClass(list, 'editable-item')[0];

      Simulate.click(item);

      expect(onSelectItem).toHaveBeenCalledWith('1', 0);
    });
  });
github salesforce-ux / design-system / ui / components / lib / control / index.react.spec.jsx View on Github external
it(`hides the div`, () => {
        let toggleable = document.querySelector('#myDiv');
        expect(toggleable.className).to.contain('show');
        Simulate.click(control, {});
        expect(toggleable.className).to.contain('hide');
      });
    });