insilico-redux-test-utils
v1.0.2
Published
Utils to help test redux actions and constants
Downloads
3
Readme
Redux Test Utils
A few simple helpers for testing redux actions and constants when using Jest.
API
uniqueConstants
Validate that all constants in a file are unique.
import { uniqueConstants } from 'insilico-redux-test-utils'
import * as constants from './constants'
test('all constants are unique', () => {
uniqueConstants(constants)
})
constantNamespace
Validate that that constant value has the correct namespace.
The namespace should begin with @@${namespace}
.
export const PERFORM_SEARCH = '@@search/PERFORM_SEARCH'
import { constantNamespace } from 'insilico-redux-test-utils'
import * as constants from './constants'
test('key contains namespace', () => {
constantNamespace(constants, 'search')
})
constantPartOfValue
Validate that that constant name is part of the actual string value. Doing this ensures no confusing names, or missing renaming doing refactoring.
import { constantPartOfValue } from 'insilico-redux-test-utils'
import * as constants from './constants'
test('key contained in value', () => {
constantPartOfValue(constants)
})
actionsConformToFSA
Validate that all actions conform to the Flux Standard Action spec
https://github.com/acdlite/flux-standard-action
import { actionsConformToFSA } from 'insilico-redux-test-utils'
import * as actions from './actions'
test('all actions conform to FSA spec', () => {
actionsConformToFSA(actions)
})