<commit_before><commit_msg>#142 added test for createListener<commit_after>import createListener from '../../lib/utils/createListener'
import React, { Component } from 'react'
import Chai, { expect } from 'chai'
import sinon from 'sinon'
import sinonChai from 'sinon-chai'
Chai.use(sinonChai)

describe('Creating an event listener', () => {

  class Example extends Component {
    render() {
      return <div onClick={this.props.onClick}></div>
    }
  }

  console.log(Example)
  const listenerFunc = sinon.spy()
  const customListenerFunc = sinon.spy()

  const rendered = <Example onClick={listenerFunc} />

  const onClick = createListener({state: {_look: new Map()}}, rendered, 'hover', 'onClick', customListenerFunc)
  const cloned = React.cloneElement(rendered, {onClick})
  cloned.props.onClick()

  it('should call existing listeners', () => {
    expect(listenerFunc).to.have.been.called
  })

  it('should call custom listeners', () => {
    expect(customListenerFunc).to.have.been.called
  })
})

{'fraction_non_alphanumeric': 0.14257425742574256, 'fraction_numerical': 0.0029702970297029703, 'mean_word_length': 4.464864864864865, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, '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': '5608907', 'n_tokens_mistral': 318, 'n_tokens_neox': 304, 'n_words': 75}