Skip to content

Commit

Permalink
feature/ValidSelectorsTypes fixes return Selectors types by types.js.…
Browse files Browse the repository at this point in the history
…flow (#3634)
  • Loading branch information
alex-shatalov authored and erikras committed Nov 23, 2017
1 parent 81169ce commit 24f4dff
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/selectors/__tests__/getFormMeta.spec.js
Expand Up @@ -50,7 +50,7 @@ const describeGetFormMeta = (name, structure, setup) => {
})
})

it('should return undefined if there are no fields', () => {
it('should return object if there are no fields', () => {
expect(
getFormMeta('foo')(
fromJS({
Expand All @@ -59,7 +59,7 @@ const describeGetFormMeta = (name, structure, setup) => {
}
})
)
).toEqual(undefined)
).toEqual(fromJS({}))
})

it('should use getFormState if provided', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/selectors/__tests__/getFormSubmitErrors.spec.js
Expand Up @@ -38,7 +38,7 @@ const describeGetFormSubmitErrors = (name, structure, setup) => {
})
})

it('should return undefined if there are no submitErrors', () => {
it('should return object if there are no submitErrors', () => {
expect(
getFormSubmitErrors('foo')(
fromJS({
Expand All @@ -47,7 +47,7 @@ const describeGetFormSubmitErrors = (name, structure, setup) => {
}
})
)
).toEqual(undefined)
).toEqual(fromJS({}))
})

it('should use getFormState if provided', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/selectors/__tests__/getFormSyncErrors.spec.js
Expand Up @@ -38,7 +38,7 @@ const describeGetFormSyncErrors = (name, structure, setup) => {
})
})

it('should return undefined if there are no syncErrors', () => {
it('should return object if there are no syncErrors', () => {
expect(
getFormSyncErrors('foo')(
fromJS({
Expand All @@ -47,7 +47,7 @@ const describeGetFormSyncErrors = (name, structure, setup) => {
}
})
)
).toEqual(undefined)
).toEqual(fromJS({}))
})

it('should use getFormState if provided', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/selectors/__tests__/getFormSyncWarnings.spec.js
Expand Up @@ -38,7 +38,7 @@ const describeGetFormSyncErrors = (name, structure, setup) => {
})
})

it('should return undefined if there are no syncWarnings', () => {
it('should return object if there are no syncWarnings', () => {
expect(
getFormSyncWarnings('foo')(
fromJS({
Expand All @@ -47,7 +47,7 @@ const describeGetFormSyncErrors = (name, structure, setup) => {
}
})
)
).toEqual(undefined)
).toEqual(fromJS({}))
})

it('should use getFormState if provided', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/selectors/getFormMeta.js
Expand Up @@ -2,13 +2,13 @@
import type { Structure, GetFormState } from '../types'
import type { GetFormMetaInterface } from './getFormMeta.types'

const createGetFormMeta = ({ getIn }: Structure<*, *>) => (
const createGetFormMeta = ({ getIn, empty }: Structure<*, *>) => (
form: string,
getFormState: ?GetFormState
): GetFormMetaInterface => (state: any) => {
const nonNullGetFormState: GetFormState =
getFormState || (state => getIn(state, 'form'))
return getIn(nonNullGetFormState(state), `${form}.fields`)
return getIn(nonNullGetFormState(state), `${form}.fields`) || empty
}

export default createGetFormMeta
4 changes: 2 additions & 2 deletions src/selectors/getFormSubmitErrors.js
Expand Up @@ -2,13 +2,13 @@
import type { Structure, GetFormState } from '../types'
import type { GetFormSubmitErrorsInterface } from './getFormSubmitErrors.types'

const createGetFormSubmitErrors = ({ getIn }: Structure<*, *>) => (
const createGetFormSubmitErrors = ({ getIn, empty }: Structure<*, *>) => (
form: string,
getFormState: ?GetFormState
): GetFormSubmitErrorsInterface => (state: any) => {
const nonNullGetFormState: GetFormState =
getFormState || (state => getIn(state, 'form'))
return getIn(nonNullGetFormState(state), `${form}.submitErrors`)
return getIn(nonNullGetFormState(state), `${form}.submitErrors`) || empty
}

export default createGetFormSubmitErrors
4 changes: 2 additions & 2 deletions src/selectors/getFormSyncErrors.js
Expand Up @@ -2,13 +2,13 @@
import type { Structure, GetFormState } from '../types'
import type { GetFormSyncErrorsInterface } from './getFormSyncErrors.types'

const createGetFormSyncErrors = ({ getIn }: Structure<*, *>) => (
const createGetFormSyncErrors = ({ getIn, empty }: Structure<*, *>) => (
form: string,
getFormState: ?GetFormState
): GetFormSyncErrorsInterface => (state: any) => {
const nonNullGetFormState: GetFormState =
getFormState || (state => getIn(state, 'form'))
return getIn(nonNullGetFormState(state), `${form}.syncErrors`)
return getIn(nonNullGetFormState(state), `${form}.syncErrors`) || empty
}

export default createGetFormSyncErrors
4 changes: 2 additions & 2 deletions src/selectors/getFormSyncWarnings.js
Expand Up @@ -2,13 +2,13 @@
import type { Structure, GetFormState } from '../types'
import type { GetFormSyncWarningsInterface } from './getFormSyncWarnings.types'

const createGetFormSyncWarnings = ({ getIn }: Structure<*, *>) => (
const createGetFormSyncWarnings = ({ getIn, empty }: Structure<*, *>) => (
form: string,
getFormState: ?GetFormState
): GetFormSyncWarningsInterface => (state: any) => {
const nonNullGetFormState: GetFormState =
getFormState || (state => getIn(state, 'form'))
return getIn(nonNullGetFormState(state), `${form}.syncWarnings`)
return getIn(nonNullGetFormState(state), `${form}.syncWarnings`) || empty
}

export default createGetFormSyncWarnings

0 comments on commit 24f4dff

Please sign in to comment.