<commit_before>//Test that children are rendered and that submit works recursively
import React from 'react';
import Form from '../src/form';
import { shallow } from 'enzyme';

const Input = ({ error, ...props }) =>
  error
    ? <p className="error">
        {error}
      </p>
    : <input {...props} />;

test('onEnter prop gets called when keyCode is 13', () => {
  const onEnter = jest.fn();
  const wrapper = shallow(
    <Form values={{ test: 'yes!' }}>
      <Input name="test" onEnter={onEnter} />
    </Form>
  );

  wrapper.find(Input).simulate('keyup', { keyCode: 13 });

  expect(onEnter).toHaveBeenCalledTimes(1);
  expect(onEnter.mock.calls[0][0].test).toEqual('yes!');
});

test('onEnter prop not called when keyCode is 13 and rules are invalid', () => {
  const onEnter = jest.fn();
  const wrapper = shallow(
    <Form values={{ test: 'yes!' }} rules={{ test: 'min:9' }}>
      <Input name="test" onEnter={onEnter} />
    </Form>
  );

  wrapper.find(Input).simulate('keyup', { keyCode: 13 });

  expect(onEnter).toHaveBeenCalledTimes(0);
});<commit_msg>Add onKeyUp test<commit_after>//Test that children are rendered and that submit works recursively
import React from 'react';
import Form from '../src/form';
import { shallow } from 'enzyme';

const Input = ({ error, ...props }) =>
  error
    ? <p className="error">
        {error}
      </p>
    : <input {...props} />;

test('onEnter prop gets called when keyCode is 13', () => {
  const onEnter = jest.fn();
  const wrapper = shallow(
    <Form values={{ test: 'yes!' }}>
      <Input name="test" onEnter={onEnter} />
    </Form>
  );

  wrapper.find(Input).simulate('keyup', { keyCode: 13 });

  expect(onEnter).toHaveBeenCalledTimes(1);
  expect(onEnter.mock.calls[0][0].test).toEqual('yes!');
});

test('onEnter prop not called when keyCode is 13 and rules are invalid', () => {
  const onEnter = jest.fn();
  const wrapper = shallow(
    <Form values={{ test: 'yes!' }} rules={{ test: 'min:9' }}>
      <Input name="test" onEnter={onEnter} />
    </Form>
  );

  wrapper.find(Input).simulate('keyup', { keyCode: 13 });

  expect(onEnter).toHaveBeenCalledTimes(0);
});

test('onKeyUp is always called', () => {
  const onEnter = jest.fn();
  const onKeyUp = jest.fn();

  const wrapper = shallow(
    <Form values={{ test: 'yes!' }} rules={{ test: 'min:9' }}>
      <Input name="test" onEnter={onEnter} onKeyUp={onKeyUp} />
    </Form>
  );

  wrapper.find(Input).simulate('keyup', { keyCode: 13 });

  expect(onEnter).toHaveBeenCalledTimes(0);
  expect(onKeyUp).toHaveBeenCalledTimes(1);
});
{'fraction_non_alphanumeric': 0.19136522753792298, 'fraction_numerical': 0.012057565149747181, 'mean_word_length': 3.6258992805755397, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4508046', 'n_tokens_mistral': 869, 'n_tokens_neox': 855, 'n_words': 218}