<commit_before>import { expect } from 'chai';
import { shallow } from 'enzyme';
import React from 'react';
import sinon from 'sinon';
import TextFilter from '../text_filter';

describe('manager.ui.components.left_panel.test_filter', () => {
  describe('render', () => {
    it('should render input without filterText', () => {
      const wrap = shallow(<TextFilter />);
      const input = wrap.find('input').first();
      expect(input.props().placeholder).to.equal('Filter');
    });

    it('should render input with filterText', () => {
      const wrap = shallow(<TextFilter text="Filter Text" />);
      const input = wrap.find('input').first();
      expect(input.props().value).to.equal('Filter Text');
    });
  });

  describe('functions', () => {
    it('should call the onChange prop when input changes', () => {
      const onChange = sinon.spy();
      const wrap = shallow(<TextFilter onChange={onChange} />);
      const input = wrap.find('input').first();
      input.value = 'new value';
      input.simulate('change', { target: input });
      expect(onChange.calledOnce).to.equal(true);
      expect(onChange.firstCall.calledWith('new value'));
    });

    it('should call the onClear prop when the button is clicked', () => {
      const onClear = sinon.spy();
      const wrap = shallow(<TextFilter onClear={onClear} />);

      wrap.setState({ query: 'hello' });

      const clear = wrap.find('.clear');

      clear.simulate('click');
      expect(onClear.calledOnce).to.equal(true);
    });
  });
});<commit_msg>fix(storybook-ui): use Jest and enzyme matchers in text_filter<commit_after>import { shallow } from 'enzyme';
import React from 'react';
import TextFilter from '../text_filter';

describe('manager.ui.components.left_panel.test_filter', () => {
  describe('render', () => {
    test('should render input without filterText', () => {
      const wrap = shallow(<TextFilter />);
      const input = wrap.find('input').first();

      expect(input).toHaveProp('placeholder', 'Filter');
    });

    test('should render input with filterText', () => {
      const wrap = shallow(<TextFilter text="Filter Text" />);
      const input = wrap.find('input').first();

      expect(input).toHaveProp('value', 'Filter Text');
    });
  });

  describe('functions', () => {
    test('should call the onChange prop when input changes', () => {
      const onChange = jest.fn();
      const wrap = shallow(<TextFilter onChange={onChange} />);

      const input = wrap.find('input').first();
      input.value = 'new value';
      input.simulate('change', { target: input });

      expect(onChange).toHaveBeenCalledWith('new value');
    });

    test('should call the onClear prop when the button is clicked', () => {
      const onClear = jest.fn();
      const wrap = shallow(<TextFilter onClear={onClear} />);
      wrap.setState({ query: 'hello' });

      const clear = wrap.find('.clear');
      clear.simulate('click');

      expect(onClear).toHaveBeenCalled();
    });
  });
});
{'fraction_non_alphanumeric': 0.17877280265339968, 'fraction_numerical': 0.0, 'mean_word_length': 3.364688856729378, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '7663993', 'n_tokens_mistral': 868, 'n_tokens_neox': 848, 'n_words': 204}