本文整理汇总了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),
],
);
});
});