From de7388bbc196edd84c08c539c0768f3ba75e4bbf Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 27 Jul 2017 20:27:42 +0900 Subject: [PATCH] test probe --- .../probe/redux/reducer/readAllByDomain.ts | 21 ++++++++++++++++ .../probe/redux/saga/read_all_by_domain.ts | 25 ++++++++----------- .../probe/redux/state/ReadAllByDomain.ts | 9 +++++++ 3 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 src/ts/@overflow/probe/redux/reducer/readAllByDomain.ts create mode 100644 src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts diff --git a/src/ts/@overflow/probe/redux/reducer/readAllByDomain.ts b/src/ts/@overflow/probe/redux/reducer/readAllByDomain.ts new file mode 100644 index 0000000..e2a3cd4 --- /dev/null +++ b/src/ts/@overflow/probe/redux/reducer/readAllByDomain.ts @@ -0,0 +1,21 @@ +import Action from '@overflow/commons/redux/Action'; +import { ReducersMapObject } from 'redux'; +import Probe from '@overflow/probe/api/model/Probe'; + +import * as ReadAllByDomainActionTypes from '../action/read_all_by_domain'; +import ReadAllProbeByDomainState, { defaultState as readAllProbeByDomainDefaultState } from '../state/ReadAllByDomain'; + +const reducer: ReducersMapObject = { + [ReadAllByDomainActionTypes.REQUEST_SUCCESS]: + (state: ReadAllProbeByDomainState = readAllProbeByDomainDefaultState, action: Action): + ReadAllProbeByDomainState => { + return state; + }, + [ReadAllByDomainActionTypes.REQUEST_FAILURE]: + (state: ReadAllProbeByDomainState = readAllProbeByDomainDefaultState, action: Action): + ReadAllProbeByDomainState => { + return state; + }, +}; + +export default reducer; diff --git a/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts b/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts index e4c1f95..6520fa6 100644 --- a/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts +++ b/src/ts/@overflow/probe/redux/saga/read_all_by_domain.ts @@ -1,37 +1,32 @@ import { SagaIterator } from 'redux-saga'; import { call, Effect, fork, put, takeLatest } from 'redux-saga/effects'; - +import { SagaWatcher } from '@overflow/commons/redux-saga'; import AppContext from '@overflow/commons/context'; import Action from '@overflow/commons/redux/Action'; - import ProbeService from '../../api/service/ProbeService'; import * as ReadAllByDomainActions from '../action/read_all_by_domain'; import ReadAllByDomainPayload from '../payload/ReadAllByDomainPayload'; function* readAllByDomain(action: Action): SagaIterator { try { - const {domain} = action.payload; - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: true}, - // }); + const { domain } = action.payload; - const ret = yield call(AppContext.getService().readAllByDomain, domain); + let service = AppContext.getService(ProbeService); + + const ret = yield call({context: service, fn: service.readAllByDomain}, domain); - // if (responseBody.token === undefined) { - // throw new Error(MESSAGES.UNABLE_TO_FIND_TOKEN_IN_LOGIN_RESPONSE); - // } yield put(ReadAllByDomainActions.requestSuccess(ret)); } catch (e) { yield put(ReadAllByDomainActions.requestFailure(e)); + // tslint:disable-next-line:no-empty } finally { - // yield put({ - // type: types.SENDING_REQUEST, - // payload: {sendingRequest: false}, - // }); } } export function* watchReadAllByDomain(): SagaIterator { yield takeLatest(ReadAllByDomainActions.REQUEST, readAllByDomain); } + +const sagaWatchers: SagaWatcher[] = [watchReadAllByDomain]; + +export default sagaWatchers; diff --git a/src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts b/src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts new file mode 100644 index 0000000..fc4378e --- /dev/null +++ b/src/ts/@overflow/probe/redux/state/ReadAllByDomain.ts @@ -0,0 +1,9 @@ +export interface State { + readonly error?: Error; +} + +export const defaultState: State = { + error: undefined, +}; + +export default State;