<commit_before>import React from 'react';
import { render, mount } from 'enzyme';

import padStart from 'lodash.padstart'

import TimePicker from '../src/timepicker';

describe("TimePicker component", ()=>{

  describe("initialization", ()=>{
    test("default value is 12", () => {
      const tp = render(<TimePicker />);
      expect(tp.find(".timepicker__display").text()).toEqual("12:00");
    })

    test("can handle a Date object input", () => {
      const t = new Date(2000,1,1,3,32,0);
      const tp = render(<TimePicker time={t} />);
      expect(tp.find(".timepicker__display").text()).toEqual("3:32");
    })

    test("can handle a simple object input", () => {
      const t = {hour:4,minute:44};
      const tp = render(<TimePicker time={t} />);
      expect(tp.find(".timepicker__display").text()).toEqual("4:44");
    })
  })

  describe("selection", ()=>{
    for (let h = 0; h < 24; ++h) {
      let hstr = padStart(h.toString(), 2, "0")

      test("clicking hour "+hstr+" selects "+hstr+":00", () => {
        const tp = mount(<TimePicker />);
        tp.find(".timegrid__hour"+hstr+" .timegrid__hourtext").simulate("click");
        expect(tp.find(".timepicker__display").text()).toEqual(h.toString()+":00");
      })

      test("clicking hour "+hstr+" calls onChange", () => {
        let mockCallback = jest.fn();
        const tp = mount(<TimePicker onChange={mockCallback} />);
        tp.find(".timegrid__hour"+hstr+" .timegrid__hourtext").simulate("click");
        expect(mockCallback.mock.calls.length).toBe(1);
        expect(mockCallback.mock.calls[0][0]).toEqual({
          hour: h,
          minute: 0
        });
      })

      for (let m of [0, 15, 30, 45]) {
        let mstr = padStart(m.toString(), 2, "0")

        test("clicking "+h.toString()+":"+mstr+" selects that hour:minute", () => {
          const tp = mount(<TimePicker />);
          tp.find(".timegrid__hour"+hstr+" .timegrid__min"+mstr).simulate("click");
          expect(tp.find(".timepicker__display").text()).toEqual(h.toString()+":"+mstr);
        })

        test("clicking "+h.toString()+":"+mstr+" calls onChange", () => {
          let mockCallback = jest.fn();
          const tp = mount(<TimePicker onChange={mockCallback} />);
          tp.find(".timegrid__hour"+hstr+" .timegrid__min"+mstr).simulate("click");
          expect(mockCallback.mock.calls.length).toBe(1);
          expect(mockCallback.mock.calls[0][0]).toEqual({
            hour: h,
            minute: m
          });
        })
      }
    }

  })

})
<commit_msg>Minor test changes<commit_after>import React from 'react';
import { render, mount } from 'enzyme';

import padStart from 'lodash.padstart'

import TimePicker from '../src/timepicker';

describe("TimePicker component", ()=>{

  describe("initialization", ()=>{
    test("default value is 12", () => {
      const tp = render(<TimePicker />);
      expect(tp.find(".timepicker__display").text()).toEqual("12:00");
    })

    test("can handle a Date object input", () => {
      const t = new Date(2000,1,1,3,32,0);
      const tp = render(<TimePicker time={t} />);
      expect(tp.find(".timepicker__display").text()).toEqual("3:32");
    })

    test("can handle a simple object input", () => {
      const t = {hour:4,minute:44};
      const tp = render(<TimePicker time={t} />);
      expect(tp.find(".timepicker__display").text()).toEqual("4:44");
    })
  })

  describe("selection", ()=>{
    for (let h = 0; h < 24; ++h) {
      let hstr = padStart(h.toString(), 2, "0")
      let hselector = ".timegrid__hour"+hstr+" .timegrid__hourtext"

      test("clicking hour "+hstr+" displays "+hstr+":00", () => {
        const tp = mount(<TimePicker />);
        tp.find(hselector).simulate("click");
        expect(tp.find(".timepicker__display").text()).toEqual(h.toString()+":00");
      })

      test("clicking hour "+hstr+" calls onChange", () => {
        let mockCallback = jest.fn();
        const tp = mount(<TimePicker onChange={mockCallback} />);
        tp.find(hselector).simulate("click");
        expect(mockCallback.mock.calls.length).toBe(1);
        expect(mockCallback.mock.calls[0][0]).toEqual({
          hour: h,
          minute: 0
        });
      })

      for (let m of [0, 15, 30, 45]) {
        let mstr = padStart(m.toString(), 2, "0")
        let hmstr = h.toString()+":"+mstr;

        test("clicking "+hmstr+" displays that hour:minute", () => {
          const tp = mount(<TimePicker />);
          tp.find(".timegrid__hour"+hstr+" .timegrid__min"+mstr).simulate("click");
          expect(tp.find(".timepicker__display").text()).toEqual(hmstr);
        })

        test("clicking "+hmstr+" calls onChange", () => {
          let mockCallback = jest.fn();
          const tp = mount(<TimePicker onChange={mockCallback} />);
          tp.find(".timegrid__hour"+hstr+" .timegrid__min"+mstr).simulate("click");
          expect(mockCallback.mock.calls.length).toBe(1);
          expect(mockCallback.mock.calls[0][0]).toEqual({
            hour: h,
            minute: m
          });
        })
      }
    }

  })

})

{'fraction_non_alphanumeric': 0.19854958839670717, 'fraction_numerical': 0.01960015680125441, 'mean_word_length': 2.7632743362831858, 'pattern_counts': {'":': 8, '<': 19, '<?xml version=': 0, '>': 37, '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': '2324654', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1607, 'n_words': 295}