2017-06-30 6 views
0

私は壮大なテストを行っています。問題?私は遅れを使う。模擬遅延の可能性はありますか?

export const displayToasterEpic = (action$, store) => 
    action$ 
    .ofType(SHOW_TOASTER) 
    .filter(action => action.toaster.show) 
    .delay(getToaster(store.getState()).duration || DELAY_TOASTER) 
    .map(() => showToaster(MESSAGE_CLOSE)); 

私のテストを参照してください:

describe('displayToasterEpic',() => { 
    it('should display toaster delete account',() => { 
     const expectedAction1 = { 
     type: SHOW_TOASTER, 
     toaster: MESSAGE_DELETE_ACCOUNT, 
     }; 
     const expectedAction2 = { 
     type: SHOW_TOASTER, 
     toaster: MESSAGE_CLOSE, 
     }; 

     store = mockStore(displayToasterEpic); 

     store.dispatch(expectedAction1); 

     expect(store.getActions()).toEqual([expectedAction1, expectedAction2]); 
    }); 

problemeがこの遅延です。同じ問題ときjest.clearAllTimers();

enter image description here

任意のアイデア?

+0

を使用(あなたused'jest.useFakeTimersを持っている) '' jest.runAllTimers()を使用した場合; ' –

答えて

0

私は自分自身のモック遅延にかなり解決策を見つけます。メソッドspyOn :)

関連する問題