all files / src/__tests__/ reducer.startAsyncValidation.spec.js

100% Statements 19/19
100% Branches 4/4
100% Functions 5/5
100% Lines 8/8
6 statements, 1 function, 3 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55                                                                                               
import {startAsyncValidation} from '../actions'
 
const describeStartAsyncValidation = (reducer, expect, {fromJS}) => () => {
  it('should set asyncValidating on startAsyncValidation', () => {
    const state = reducer(fromJS({
      foo: {
        doesnt: 'matter',
        should: 'notchange'
      }
    }), {
      ...startAsyncValidation(),
      form: 'foo'
    })
    expect(state)
      .toEqualMap({
        foo: {
          doesnt: 'matter',
          should: 'notchange',
          asyncValidating: true
        }
      })
  })
 
  it('should set asyncValidating with field name on startAsyncValidation', () => {
    const state = reducer(fromJS({
      foo: {
        values: {
          myField: 'initialValue'
        },
        initial: {
          myField: 'initialValue'
        }
      }
    }), {
      ...startAsyncValidation(),
      form: 'foo',
      field: 'myField'
    })
    expect(state)
      .toEqualMap({
        foo: {
          values: {
            myField: 'initialValue'
          },
          initial: {
            myField: 'initialValue'
          },
          asyncValidating: 'myField'
        }
      })
  })
}
 
export default describeStartAsyncValidation