How to use the redux-saga-test-plan/providers.throwError function in redux-saga-test-plan

To help you get started, we’ve selected a few redux-saga-test-plan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sovrin-foundation / connector-app / app / store / __tests__ / config-store.spec.js View on Github external
it('initVcx, fail init', () => {
    const errorMessage = 'test init fail error'
    const failInitError = new Error(errorMessage)

    return expectSaga(initVcx)
      .withState(notHydratedNoOneTimeInfoState)
      .dispatch({ type: HYDRATED })
      .provide([
        [matchers.call.fn(createOneTimeInfo, agencyConfig), userOneTimeInfo],
        [
          matchers.call.fn(init, { ...userOneTimeInfo, ...agencyConfig }),
          throwError(failInitError),
        ],
      ])
      .put(connectRegisterCreateAgentDone(userOneTimeInfo))
      .put(vcxInitFail(ERROR_VCX_INIT_FAIL(errorMessage)))
      .run()
  })
github sovrin-foundation / connector-app / app / store / __tests__ / config-store.spec.js View on Github external
it('initVcx, fail provision', () => {
    const errorMessage = 'test provision fail error'
    const failProvisionError = new Error(errorMessage)

    return expectSaga(initVcx)
      .withState(notHydratedNoOneTimeInfoState)
      .dispatch({ type: HYDRATED })
      .provide([
        [
          matchers.call.fn(createOneTimeInfo, agencyConfig),
          throwError(failProvisionError),
        ],
        [matchers.call.fn(vcxShutdown, false), true],
      ])
      .put(vcxInitFail(ERROR_VCX_PROVISION_FAIL(errorMessage)))
      .run()
  })
github sovrin-foundation / connector-app / app / claim-offer / __tests__ / claim-offer-store.spec.js View on Github external
const failSaveSerializedClaimOffers = new Error(errorMessage)

    return expectSaga(
      saveClaimOffersSaga,
      addSerializedClaimOffer(
        serializedClaimOffer,
        pairwiseConnection.identifier,
        uid,
        claimOfferVcxInitialState
      )
    )
      .withState({ claimOffer: { vcxSerializedClaimOffers: {} } })
      .provide([
        [
          matchers.call.fn(secureSet, CLAIM_OFFERS, '{}'),
          throwError(failSaveSerializedClaimOffers),
        ],
      ])
      .put({
        type: SAVE_CLAIM_OFFERS_FAIL,
        error: ERROR_SAVE_CLAIM_OFFERS(errorMessage),
      })
      .run()
  })
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / store / sqlStats / sqlStats.sagas.spec.ts View on Github external
it("returns error on failed reset", () => {
      const err = new Error("failed to reset");
      expectSaga(resetSQLStatsSaga)
        .provide([[matchers.call.fn(resetSQLStats), throwError(err)]])
        .put(sqlStatsActions.failed(err))
        .withReducer(sqlStatsReducers)
        .hasFinalState({
          data: null,
          lastError: err,
          valid: false,
        })
        .run();
    });
  });
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / store / liveness / liveness.sagas.spec.ts View on Github external
it("returns error on failed request", () => {
      const error = new Error("Failed request");
      expectSaga(requestLivenessSaga)
        .provide([[matchers.call.fn(getLiveness), throwError(error)]])
        .put(actions.failed(error))
        .withReducer(reducer)
        .hasFinalState({
          data: null,
          lastError: error,
          valid: false,
        })
        .run();
    });
  });
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / store / nodes / nodes.sagas.spec.ts View on Github external
it("returns error on failed request", () => {
      const error = new Error("Failed request");
      expectSaga(requestNodesSaga)
        .provide([[matchers.call.fn(getNodes), throwError(error)]])
        .put(actions.failed(error))
        .withReducer(reducer)
        .hasFinalState({
          data: null,
          lastError: error,
          valid: false,
        })
        .run();
    });
  });
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / store / statements / statements.sagas.spec.ts View on Github external
it("returns error on failed request", () => {
      const error = new Error("Failed request");
      expectSaga(requestStatementsSaga)
        .provide([[matchers.call.fn(getStatements), throwError(error)]])
        .put(actions.failed(error))
        .withReducer(reducer)
        .hasFinalState({
          data: null,
          lastError: error,
          valid: false,
        })
        .run();
    });
  });
github cockroachdb / cockroach-gen / pkg / ui / src / redux / statements / statementsSagas.spec.ts View on Github external
it("calls dispatched failed action if api#createStatementDiagnosticsReport request failed ", () => {
    const statementFingerprint = "some-id";
    const action = createStatementDiagnosticsReportAction(statementFingerprint);
    const diagnosticsReportRequest = new CreateStatementDiagnosticsReportRequest(
      {
        statement_fingerprint: statementFingerprint,
      },
    );

    return expectSaga(createDiagnosticsReportSaga, action)
      .provide([
        [call.fn(createStatementDiagnosticsReport), throwError(new Error())],
      ])
      .call(createStatementDiagnosticsReport, diagnosticsReportRequest)
      .put(createStatementDiagnosticsReportFailedAction())
      .dispatch(action)
      .run();
  });
});
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / store / statementDiagnostics / statementDiagnostics.sagas.spec.ts View on Github external
it("failed request", () => {
      const error = new Error("Failed request");
      expectSaga(
        createDiagnosticsReportSaga,
        actions.createReport(statementFingerprint),
      )
        .provide([
          [
            call(createStatementDiagnosticsReport, statementFingerprint),
            throwError(error),
          ],
          [call(getStatementDiagnosticsReports), reportsResponse],
        ])
        .put(actions.createReportFailed(error))
        .run();
    });
  });
github cockroachdb / cockroach-gen / pkg / ui / cluster-ui / src / store / statementDiagnostics / statementDiagnostics.sagas.spec.ts View on Github external
it("fails to request diagnostics reports", () => {
      const error = new Error("Failed request");
      expectSaga(requestStatementsDiagnosticsSaga)
        .provide([[call(getStatementDiagnosticsReports), throwError(error)]])
        .put(actions.failed(error))
        .withReducer(reducer)
        .hasFinalState({
          data: null,
          lastError: error,
          valid: false,
        })
        .run();
    });
  });