jfairbank / redux-saga-test-plan

Test Redux Saga with an easy plan.
http://redux-saga-test-plan.jeremyfairbank.com
MIT License
1.25k stars 127 forks source link

Debounce support #276

Open cdow opened 5 years ago

cdow commented 5 years ago

Please implement support for the debounce effect.

cdow commented 5 years ago

I've since realized that this effect can be easily tested for in unit tests by making use of the is method. So, this can be closed if there is no desire to add first class support.

AntwanSherif commented 5 years ago

@cdow Could you please provide a sample code?

mllustosa commented 5 years ago

@AntwanSherif I think he meant something like:

import { testSaga } from 'redux-saga-test-plan';
import { debounce } from 'redux-saga/effects';
import * as sagas from '../sagas';

describe('My component sagas', () => {
  it('should do something', () => {
    testSaga(sagas.mySaga)
      .next()
      .is(debounce(200, 'MY-CONSTANT', someFn))
      .next()
      .isDone();
  });
});

However, you could then say that this would work for every baked-in function in the API, as in, you could also write .is(takeLatest) instead of .takeLatest and so on. Having said that, I think it would be benefitial for the .debounce to be part of the API. To keep it consistent with the other calls and avoid using this escape hatch.

AntwanSherif commented 5 years ago

@mllustosa Thanks a lot. It works like a charm <3