<commit_before>import React from 'react';
import renderer from 'react-test-renderer';

import TimePicker, {
  parseInTimeFormat, H24, H12, toOption, filterTime, createTimeList, makeOptions, inputError
} from '../../src/time-picker/TimePicker';

// Because of this bug: https://github.com/facebook/react/issues/7386
// Should be fixed in react 15.4
jest.mock('react-dom');

const exampleProps = {
  ...TimePicker.defaultProps,
  id: '12345',
  className: 'fancy-class-name',
  placeholder: '--:--',
  timeFormat: '24h',
  style: { margin: 10, position: 'relative' },
  value: { hours: 6, minutes: 30 },
  minTime: { hours: 5, minutes: 10 },
  maxTime: { hours: 8, minutes: 20 },
  onChange: () => {}
};

const timePicker = new TimePicker(exampleProps);

describe('TimePicker', () => {

  // ignored because react-dom is mocked (see above)
  // it causes problem with AutosizeInput when using refs
  xit('renders correctly', () => {
    const component = renderer.create(
      <TimePicker {...exampleProps} />
    );
    expect(component).toMatchSnapshot();
  });

  describe('getLocals', () => {

    it('computes className', () => {
      const { className } = timePicker.getLocals();
      expect(className).toContain('time-picker');
      expect(className).toContain('fancy-class-name');
    });

    it('passes value properly formatted when H24', () => {
      const timePicker = new TimePicker({
        ...TimePicker.defaultProps,
        value: { hours: 15, minutes: 33 }
      });
      const { value } = timePicker.getLocals();
      expect(value).toEqual({ value: '15:33', label: '15:33' });
    });

    it('passes value properly formatted when H12', () => {
      const timePicker = new TimePicker({
        ...TimePicker.defaultProps,
        value: { hours: 15, minutes: 33 },
        timeFormat: H12
      });
      const { value } = timePicker.getLocals();
      expect(value).toEqual({ value: '15:33', label: '03:33 pm' });
    });
<commit_msg>Change the test of timepicker to compare to the value not to the option object {value:xx, label:xx}<commit_after>import React from 'react';
import renderer from 'react-test-renderer';

import TimePicker, {
  parseInTimeFormat, H24, H12, toOption, filterTime, createTimeList, makeOptions, inputError
} from '../../src/time-picker/TimePicker';

// Because of this bug: https://github.com/facebook/react/issues/7386
// Should be fixed in react 15.4
jest.mock('react-dom');

const exampleProps = {
  ...TimePicker.defaultProps,
  id: '12345',
  className: 'fancy-class-name',
  placeholder: '--:--',
  timeFormat: '24h',
  style: { margin: 10, position: 'relative' },
  value: { hours: 6, minutes: 30 },
  minTime: { hours: 5, minutes: 10 },
  maxTime: { hours: 8, minutes: 20 },
  onChange: () => {}
};

const timePicker = new TimePicker(exampleProps);

describe('TimePicker', () => {

  // ignored because react-dom is mocked (see above)
  // it causes problem with AutosizeInput when using refs
  xit('renders correctly', () => {
    const component = renderer.create(
      <TimePicker {...exampleProps} />
    );
    expect(component).toMatchSnapshot();
  });

  describe('getLocals', () => {

    it('computes className', () => {
      const { className } = timePicker.getLocals();
      expect(className).toContain('time-picker');
      expect(className).toContain('fancy-class-name');
    });

    it('passes value properly formatted when H24', () => {
      const timePicker = new TimePicker({
        ...TimePicker.defaultProps,
        value: { hours: 15, minutes: 33 }
      });
      const { value } = timePicker.getLocals();
      expect(value).toEqual('15:33');
    });

    it('passes value properly formatted when H12', () => {
      const timePicker = new TimePicker({
        ...TimePicker.defaultProps,
        value: { hours: 15, minutes: 33 },
        timeFormat: H12
      });
      const { value } = timePicker.getLocals();
      expect(value).toEqual('15:33');
    });

{'fraction_non_alphanumeric': 0.16375601113642116, 'fraction_numerical': 0.027841052898000505, 'mean_word_length': 3.1775898520084565, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '3085444', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1198, 'n_words': 307}