redux-box icon indicating copy to clipboard operation
redux-box copied to clipboard

Example with Testing

Open abtinr opened this issue 6 years ago • 1 comments

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

abtinr avatar May 22 '18 21:05 abtinr

@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!

anish000kumar avatar Sep 10 '18 09:09 anish000kumar