import { effects } from 'ferp';
const IncrementCounterByN = n => state => [
{ ...state, counter: state.counter + n },
effects.none(),
];
describe('IncremenetCounterByN', () => {
it('increments the counter state variable using the provided value', () => {
const initialState = { counter: 0 };
const [state, _effect] = IncrementCounterByN(999)(initialState);
expect(state).toDeepEqual({
counter: 999,
});
});
});
Result of Side-Effects
Testing that the correct side effects can be a little more tricky. The problem is that effects touch the outside world that is not controlled by Ferp. Running these end-to-end just like the effect testing is likely your best bet.