anish000kumar / redux-box

Modular and easy-to-grasp redux based state management, with least boilerplate
MIT License
708 stars 25 forks source link

Example with Testing #17

Open abtinr opened 6 years ago

abtinr commented 6 years ago

Thanks for this useful package and all the examples.

I couldn't find any example with a test. Specifically, I am interested in testing sagas. It seems the approach proposed in redux-saga (https://redux-saga.js.org/docs/advanced/Testing.html) is not applicable here or at least is not very straight forward. Appreciate if you provide a test case for sagas.

Thanks

anish000kumar commented 6 years ago

@abtinr you can import the generators from sagas.js file like so:

import { createSagas } from "redux-box"

export const sagas = {
  'REQUEST_SOMETHING': function* () { //... }
}

export default createSagas(sagas)

sagas.spec.js

import {sagas} from "./sagas"
//  test generator sagas.REQUEST_SOMETHING as per redux-saga docs

Hope it helps!