<commit_before><commit_msg>Tests finished.<commit_after>import React from 'react'
import ReactDOM from 'react-dom'
import TestUtils from 'react-addons-test-utils'
import {describe, before, it} from 'mocha'
import expect from 'expect'
import {createStore, applyMiddleware} from 'redux'
import {combineReducers} from 'redux-immutablejs'
import thunk from 'redux-thunk'
import {Provider} from 'react-redux'

import I18n from '../immutable'
import {i18nState} from '../immutable'
import {setLanguage, setTranslations} from '../dist/actions'

import TransWithoutParams from './components/TransWithoutParams'

describe('translations in reducer (immutable)', function() {
  before('rendering component', function() {
    this.store = createStore(
      combineReducers({i18nState}),
      applyMiddleware(thunk)
    )

    this.component = ReactDOM.findDOMNode(TestUtils.renderIntoDocument(
      <Provider store={this.store}>
        <I18n translations={{}} useReducer={true}>
          <TransWithoutParams/>
        </I18n>
      </Provider>
    ))

  })

  it('default component', function() {
    expect(this.store.getState().getIn(['i18nState', 'translations'])).toEqual({})
    this.store.dispatch(setLanguage('es'))
    expect(this.component.textContent).toEqual('Hello')

    const trans = {
      'es': {
        'Hello': 'Hola'
      }
    }

    this.store.dispatch(setTranslations(trans))
    expect(this.store.getState().getIn(['i18nState', 'translations'])['es']['Hello']).toEqual('Hola')
    expect(this.component.textContent).toEqual('Hola')
  })
})
{'fraction_non_alphanumeric': 0.1521181001283697, 'fraction_numerical': 0.008985879332477536, 'mean_word_length': 4.357388316151202, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '7474312', 'n_tokens_mistral': 488, 'n_tokens_neox': 482, 'n_words': 95}