當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript redux-saga-test-plan.expectSaga函數代碼示例

本文整理匯總了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);
         });
 });
開發者ID:asubiotto,項目名稱:cockroach,代碼行數:8,代碼來源:saga.spec.ts

示例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),
              ],
            );
          });
      });
開發者ID:a6802739,項目名稱:cockroach,代碼行數:48,代碼來源:metrics.spec.ts


注:本文中的redux-saga-test-plan.expectSaga函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。