1.0.1 • Published 5 years ago

redux-reducer-test-plan v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

NPM version Codacy Badge Build Status Coverage Status

redux-reducer-test-plan

Easily test reducers by passing a state, action and expected result.

Install

yarn install redux-reducer-test-plan

Usage

To run the test just pass the reducer into the function and then set the state, action and expected result. Finally to execute the test call .run()

const TestReducer = require("redux-reducer-test-plan")

describe("Some test", () => {
  it("some test case", () => {
    TestReducer(reducer)
      .state({ a: true })
      .action({ type: "ACTION" })
      .expect({ a: false })
      .run()
  })
})

.expect can be a value or a function. If it is a function is calls the passing function with following values:

result and prevState