How to use the react-addons-test-utils.Simulate.blur 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 mozilla / addons-frontend / tests / unit / ui / components / TestSearchInput.js View on Github external
it('forwards the onBlur event', () => {
    const spy = sinon.spy();
    const root = renderIntoDocument();
    Simulate.blur(root.input);
    sinon.assert.callCount(spy, 1);
  });
github systemaccounting / mxfactorial / test / app / components / Transaction / TransactionItem.spec.js View on Github external
it('should handleUpdateField when user change value', () => {
    instance = renderIntoDocument();
    const [itemInput, valueInput, quantityInput] = scryRenderedDOMComponentsWithTag(instance, 'input');

    itemInput.value = 'item';
    Simulate.blur(itemInput);
    props.handleUpdateField.should.be.calledWith('name');

    valueInput.value = 30;
    Simulate.blur(valueInput);
    props.handleUpdateField.should.be.calledWith('value');

    quantityInput.value = 1;
    ReactTestUtils.Simulate.change(quantityInput);
    props.handleUpdateField.should.be.calledWith('quantity');
  });
github systemaccounting / mxfactorial / test / app / components / Transaction / TransactionItem.spec.js View on Github external
it('should handleUpdateField when user change value', () => {
    instance = renderIntoDocument();
    const [itemInput, valueInput, quantityInput] = scryRenderedDOMComponentsWithTag(instance, 'input');

    itemInput.value = 'item';
    Simulate.blur(itemInput);
    props.handleUpdateField.should.be.calledWith('name');

    valueInput.value = 30;
    Simulate.blur(valueInput);
    props.handleUpdateField.should.be.calledWith('value');

    quantityInput.value = 1;
    ReactTestUtils.Simulate.change(quantityInput);
    props.handleUpdateField.should.be.calledWith('quantity');
  });
github mlaursen / react-md / src / js / Tooltips / __tests__ / Tooltips.js View on Github external
onTouchEnd={onTouchEnd}
        onKeyUp={onKeyUp}
        onKeyDown={onKeyDown}
      >
        Hello!
      
    );

    const testNode = findRenderedDOMComponentWithTag(tooltipTest, 'a');
    const event = { pageX: 0, pageY: 0 };
    const touchEvent = { changedTouches: [event] };
    Simulate.mouseDown(testNode, event);
    Simulate.mouseUp(testNode, event);
    Simulate.mouseLeave(testNode, event);
    Simulate.focus(testNode);
    Simulate.blur(testNode);
    Simulate.touchStart(testNode, touchEvent);
    Simulate.touchMove(testNode, touchEvent);
    Simulate.touchCancel(testNode, touchEvent);
    Simulate.touchEnd(testNode, touchEvent);
    Simulate.keyUp(testNode);
    Simulate.keyDown(testNode);

    expect(onMouseDown.mock.calls.length).toBe(1);
    expect(onMouseUp.mock.calls.length).toBe(1);
    expect(onMouseLeave.mock.calls.length).toBe(1);
    expect(onFocus.mock.calls.length).toBe(1);
    expect(onBlur.mock.calls.length).toBe(1);
    expect(onTouchStart.mock.calls.length).toBe(1);
    expect(onTouchMove.mock.calls.length).toBe(1);
    expect(onTouchCancel.mock.calls.length).toBe(1);
    expect(onTouchEnd.mock.calls.length).toBe(1);
github mlaursen / react-md / src / js / BottomNavigations_old / __tests__ / BottomNav.js View on Github external
fixed: false,
      label: 'A',
      onNavChange: jest.fn(),
      index: 0,
    };

    const nav = renderIntoDocument();
    const navNode = findDOMNode(nav);

    Simulate.click(navNode);
    expect(onClick.mock.calls.length).toBe(1);

    Simulate.focus(navNode);
    expect(onFocus.mock.calls.length).toBe(1);

    Simulate.blur(navNode);
    expect(onBlur.mock.calls.length).toBe(1);

    Simulate.mouseDown(navNode);
    expect(onMouseDown.mock.calls.length).toBe(1);

    Simulate.mouseUp(navNode);
    expect(onMouseUp.mock.calls.length).toBe(1);

    Simulate.mouseOver(navNode);
    expect(onMouseOver.mock.calls.length).toBe(1);

    Simulate.mouseLeave(navNode);
    expect(onMouseLeave.mock.calls.length).toBe(1);

    Simulate.touchStart(navNode);
    expect(onTouchStart.mock.calls.length).toBe(1);
github systemaccounting / mxfactorial / test / app / components / AccountSetting / AccountSettingSection.spec.js View on Github external
instance = renderIntoDocument(
      
        
      
    );

    const push = spy();

    const ascInstance = findRenderedComponentWithType(instance, AccountSettingSection);
    ascInstance.context.router = { push };

    const emailInput = findRenderedDOMComponentWithClass(instance, 'email--input');
    emailInput.value='newmail@mail.com';
    ReactTestUtils.Simulate.change(emailInput);

    Simulate.blur(emailInput);

    push.should.be.calledWith({
      pathname: '/AccountSetting/NewEmail',
      query: {
        email: 'newmail@mail.com'
      }
    });
  });
github systemaccounting / mxfactorial / test / app / components / Transaction / TransactionSection.spec.js View on Github external
const transactionPopup = findRenderedComponentWithType(instance, TransactionPopup);
    findRenderedDOMComponentWithClass(transactionPopup, 'transaction-amount').textContent.should.equal('(25.000)');
    const cancelBtn = findRenderedDOMComponentWithClass(transactionPopup, 'btn__cancel');
    Simulate.click(cancelBtn);
    props.updateError.should.be.calledOnce();
    scryRenderedComponentsWithType(instance, TransactionPopup).length.should.equal(0);

    const transactionItem = findRenderedComponentWithType(instance, TransactionItem);

    const [itemInput, valueInput, quantityInput] = scryRenderedDOMComponentsWithTag(transactionItem, 'input');
    itemInput.value.should.equal('item1');
    valueInput.value.should.equal('25.000');
    quantityInput.value.should.equal('1');
    itemInput.value = 'item2';
    Simulate.blur(itemInput);
    props.updateTransaction.should.be.calledWith({
      key: 0,
      field: 'name',
      value: 'item2'
    });

    const btnRemove = findRenderedDOMComponentWithClass(transactionItem, 'btn__remove');
    Simulate.click(btnRemove);
    props.removeTransaction.should.be.calledWith(0);
  });
github nylas-mail-lives / nylas-mail / spec / components / editable-list-spec.jsx View on Github external
it('renders correctly when item is in editing state', () => {
      const onInputBlur = jasmine.createSpy('onInputBlur');
      const onInputFocus = jasmine.createSpy('onInputFocus');
      const onInputKeyDown = jasmine.createSpy('onInputKeyDown');

      const item = makeItem('item 1', 0, {editingIndex: 0}, {onInputBlur, onInputFocus, onInputKeyDown});
      const input = item.querySelector('input')

      Simulate.focus(input);
      Simulate.keyDown(input);
      Simulate.blur(input);

      expect(onInputFocus).toHaveBeenCalled();
      expect(onInputBlur).toHaveBeenCalled();
      expect(onInputKeyDown.calls[0].args[1]).toEqual('item 1');
      expect(onInputKeyDown.calls[0].args[2]).toEqual(0);

      expect(findDOMNode(input).tagName).toEqual('INPUT');
    });
  });