test probe

This commit is contained in:
insanity 2017-07-27 20:27:42 +09:00
parent 52eda63df7
commit de7388bbc1
3 changed files with 40 additions and 15 deletions

View File

@ -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<Probe>):
ReadAllProbeByDomainState => {
return state;
},
[ReadAllByDomainActionTypes.REQUEST_FAILURE]:
(state: ReadAllProbeByDomainState = readAllProbeByDomainDefaultState, action: Action<Error>):
ReadAllProbeByDomainState => {
return state;
},
};
export default reducer;

View File

@ -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<ReadAllByDomainPayload>): 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<ProbeService>().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;

View File

@ -0,0 +1,9 @@
export interface State {
readonly error?: Error;
}
export const defaultState: State = {
error: undefined,
};
export default State;