redux-saga-test-plan icon indicating copy to clipboard operation
redux-saga-test-plan copied to clipboard

Debounce support

Open cdow opened this issue 5 years ago • 4 comments

Please implement support for the debounce effect.

cdow avatar May 17 '19 00:05 cdow

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.

cdow avatar May 23 '19 23:05 cdow

@cdow Could you please provide a sample code?

AntwanSherif avatar Aug 25 '19 18:08 AntwanSherif

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

mllustosa avatar Nov 28 '19 12:11 mllustosa

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

AntwanSherif avatar Nov 28 '19 13:11 AntwanSherif