Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test self cancellation? #382

Open
kodmigor opened this issue Mar 7, 2022 · 0 comments
Open

How to test self cancellation? #382

kodmigor opened this issue Mar 7, 2022 · 0 comments

Comments

@kodmigor
Copy link

kodmigor commented Mar 7, 2022

Hi, everyone!

I have a saga with infinity loop, where it takes an action and depending on action's payload yield self cancellation.
How this case may be tested correctly?

function* sagaWorker() {
  while (true) {
    const action = yield take("ACTION");
    if (action.payload === "CANCEL") yield cancel();
  }
}
test(`test SELF_CANCELLATION`, () => {
  const actionInProgress = {payload: "IN_PROGRESS", type: "ACTION"};
  const actionCancel = {payload: "CANCEL", type: "ACTION"};
  testSaga(sagaWorker)
    .next()
    .take("ACTION")
    .next(actionInProgress)
    .take("ACTION")
    .next(actionCancel)
    // what must be here?
    .next()
    .isDone();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant