Narcoleptic's Patch Mangler

    insilico-redux-test-utils

    1.0.2 • Public • Published

    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)
    })

    Keywords

    none

    Install

    npm i insilico-redux-test-utils

    DownloadsWeekly Downloads

    2

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • thebuilder