本文整理匯總了TypeScript中redux-saga-test-plan.expectSaga函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript expectSaga函數的具體用法?TypeScript expectSaga怎麽用?TypeScript expectSaga使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了expectSaga函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("immediately runs a saga when refresh is called", function() {
return expectSaga(queryManagerSaga)
.dispatch(refresh(testQueryCounter))
.run()
.then(() => {
assert.equal(queryCounterCalled, 1);
});
});
示例2: it
it("correctly accumulates batches", function () {
const requestAction = metrics.requestMetrics("id", createRequest(shortTimespan, "short.1"));
const beginAction = metrics.beginMetrics(requestAction.payload.id, requestAction.payload.data);
return expectSaga(metrics.queryMetricsSaga)
// Stub out calls to batchAndSendRequests.
.provide([
[matchers.call.fn(metrics.batchAndSendRequests), null],
])
// Dispatch six requests, with delays inserted in order to trigger
// batch sends.
.dispatch(requestAction)
.dispatch(requestAction)
.dispatch(requestAction)
.delay(0)
.dispatch(requestAction)
.delay(0)
.dispatch(requestAction)
.dispatch(requestAction)
.run()
.then((result) => {
const { effects } = result;
// Verify the order of call dispatches.
assert.deepEqual(
effects.call,
[
call(delay, 0),
call(metrics.batchAndSendRequests, [requestAction.payload, requestAction.payload, requestAction.payload]),
call(delay, 0),
call(metrics.batchAndSendRequests, [requestAction.payload]),
call(delay, 0),
call(metrics.batchAndSendRequests, [requestAction.payload, requestAction.payload]),
],
);
// Verify that all beginAction puts were dispatched.
assert.deepEqual(
effects.put,
[
put(beginAction),
put(beginAction),
put(beginAction),
put(beginAction),
put(beginAction),
put(beginAction),
],
);
});
});