<commit_before>import reduceOptions, * as OptionsActions from '../../ducks/options'

import configureStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import * as OptionsEditorActions from '../../ducks/ui/optionsEditor'
import {updateError} from "../../ducks/ui/optionsEditor";

const mockStore = configureStore([ thunk ])

describe('option reducer', () => {
    it('should return initial state', () => {
        expect(reduceOptions(undefined, {})).toEqual(OptionsActions.defaultState)
    })

    it('should handle receive action', () => {
        let action = { type: OptionsActions.RECEIVE, data: {id: 'foo'} }
        expect(reduceOptions(undefined, action)).toEqual({id: 'foo'})
    })

    it('should handle update action', () => {
        let action = {type: OptionsActions.UPDATE, data: {id: 1} }
        expect(reduceOptions(undefined, action)).toEqual({...OptionsActions.defaultState, id: 1})
    })
})

let store = mockStore()

describe('option actions', () => {

    it('should be possible to update option', () => {
        let mockResponse = { status: 200 },
            promise = Promise.resolve(mockResponse)
        global.fetch = r => { return promise }<commit_msg>fix optionsSpec.js<commit_after>import reduceOptions, * as OptionsActions from '../../ducks/options'

import configureStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import * as OptionsEditorActions from '../../ducks/ui/optionsEditor'
import {updateError} from "../../ducks/ui/optionsEditor";

const mockStore = configureStore([ thunk ])

describe('option reducer', () => {
    it('should return initial state', () => {
        expect(reduceOptions(undefined, {})).toEqual(OptionsActions.defaultState)
    })

    it('should handle receive action', () => {
        let action = { type: OptionsActions.RECEIVE, data: {id: {value: 'foo'} } }
        expect(reduceOptions(undefined, action)).toEqual({id: 'foo'})
    })

    it('should handle update action', () => {
        let action = {type: OptionsActions.UPDATE, data: {id: {value: 1} } }
        expect(reduceOptions(undefined, action)).toEqual({...OptionsActions.defaultState, id: 1})
    })
})

let store = mockStore()

describe('option actions', () => {

    it('should be possible to update option', () => {
        let mockResponse = { status: 200 },
            promise = Promise.resolve(mockResponse)
        global.fetch = r => { return promise }
{'fraction_non_alphanumeric': 0.16177079023582955, 'fraction_numerical': 0.004137360364087712, 'mean_word_length': 3.4860853432282, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '5205124', 'n_tokens_mistral': 685, 'n_tokens_neox': 680, 'n_words': 173}