<commit_before>import React, { Component } from 'react'
import * as enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

import { Provider, connect } from 'react-redux'
import { createStore, combineReducers, applyMiddleware, compose } from 'redux'
import createHistory from 'history/createMemoryHistory'

import reducer from '../src/reducer'
import storeEnhancer from '../src/storeEnhancer'

enzyme.configure({ adapter: new Adapter() })

const fakeWeekReducer = (state = 1) => state

function sagaStore(state, reducers = { routing: reducer, week: fakeWeekReducer }, middleware = [],
  enhancer = storeEnhancer(createHistory({
    initialEntries: ['/']
  }))) {
  const log = []
  const logger = store => next => action => { // eslint-disable-line
    log.push(action)
    return next(action)
  }

  const store = createStore(combineReducers(reducers),
    state, compose(enhancer, applyMiddleware(...middleware, logger)))
  return {
    log,
    store,
  }
}

function renderComponent(ComponentClass, props = {}, state = undefined, returnStore = false,
  mySagaStore = sagaStore(state), intoDocument = false) {
  class Tester extends Component {
    constructor(props) {
      super(props)
      this.state = props
    }
    componentDidUpdate(props) {
      if (props !== this.props) {
        this.setState(this.props)
      }
    }
    render() {
      return (
        <Provider store={mySagaStore.store}>
          <ComponentClass {...this.state} />
        </Provider>
      )
    }
  }
  const componentInstance = enzyme.mount(
    <Tester {...props} />, intoDocument ? { attachTo: intoDocument } : undefined
  )
  const ret = componentInstance
  if (returnStore) {
    return [ret, mySagaStore.store, mySagaStore.log]
  }
  return ret
}


export { renderComponent, connect, sagaStore } // eslint-disable-line
<commit_msg>minor tweak<commit_after>import React, { Component } from 'react'
import * as enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

import { Provider, connect } from 'react-redux'
import { createStore, combineReducers, applyMiddleware, compose } from 'redux'
import createHistory from 'history/createMemoryHistory'

import reducer from '../src/reducer'
import storeEnhancer from '../src/storeEnhancer'

enzyme.configure({ adapter: new Adapter() })

const fakeWeekReducer = (state = 1) => state

function sagaStore(state, reducers = { routing: reducer, week: fakeWeekReducer }, middleware = [],
  enhancer = storeEnhancer(createHistory({
    initialEntries: ['/']
  }))) {
  const log = []
  const logger = store => next => action => { // eslint-disable-line
    log.push(action)
    return next(action)
  }

  const store = createStore(combineReducers(reducers),
    state, compose(enhancer, applyMiddleware(...middleware, logger)))
  return {
    log,
    store,
  }
}

function renderComponent(ComponentClass, props = {}, state = undefined, returnStore = false,
  mySagaStore = sagaStore(state), intoDocument = false) {
  class Tester extends Component {
    constructor(props) {
      super(props)
      this.state = props
    }
    componentDidUpdate(props) {
      if (props !== this.props) {
        this.setState(this.props)
      }
    }
    render() {
      return (
        <Provider store={mySagaStore.store}>
          <ComponentClass {...this.state} />
        </Provider>
      )
    }
  }
  const ret = enzyme.mount(
    <Tester {...props} />, intoDocument ? { attachTo: intoDocument } : undefined
  )
  if (returnStore) {
    return [ret, mySagaStore.store, mySagaStore.log]
  }
  return ret
}


export { renderComponent, connect, sagaStore } // eslint-disable-line

{'fraction_non_alphanumeric': 0.12774725274725274, 'fraction_numerical': 0.0016483516483516484, 'mean_word_length': 3.376201923076923, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, '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': '2185110', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1097, 'n_words': 268}