Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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()
})
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()
})
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()
})
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();
});
});
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();
});
});
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();
});
});
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();
});
});
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();
});
});
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();
});
});
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();
});
});