2022-07-26 10:20:39 +00:00
|
|
|
import ReducerRegistry from '../redux/ReducerRegistry';
|
|
|
|
import { assign } from '../redux/functions';
|
2018-03-07 15:23:04 +00:00
|
|
|
|
|
|
|
import { SET_CONNECTION_STATE } from './actionTypes';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The initial state of the feature testing.
|
|
|
|
*
|
|
|
|
* @type {{
|
|
|
|
* connectionState: string
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
const INITIAL_STATE = {
|
|
|
|
connectionState: ''
|
|
|
|
};
|
|
|
|
|
2022-07-26 10:20:39 +00:00
|
|
|
export interface ITestingState {
|
|
|
|
connectionState: string;
|
|
|
|
}
|
|
|
|
|
2022-09-05 09:05:07 +00:00
|
|
|
ReducerRegistry.register<ITestingState>(
|
2018-03-07 15:23:04 +00:00
|
|
|
'features/testing',
|
2022-09-05 09:05:07 +00:00
|
|
|
(state = INITIAL_STATE, action): ITestingState => {
|
2018-03-07 15:23:04 +00:00
|
|
|
switch (action.type) {
|
|
|
|
case SET_CONNECTION_STATE:
|
|
|
|
return _setConnectionState(state, action);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reduces a specific Redux action SET_CONNECTION_STATE of the feature
|
|
|
|
* testing.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state of the feature base/logging.
|
|
|
|
* @param {Action} action - The Redux action SET_CONNECTION_STATE to reduce.
|
|
|
|
* @private
|
|
|
|
* @returns {Object} The new state of the feature testing after the
|
|
|
|
* reduction of the specified action.
|
|
|
|
*/
|
2022-07-26 10:20:39 +00:00
|
|
|
function _setConnectionState(state: ITestingState, action: any) {
|
2018-03-07 15:23:04 +00:00
|
|
|
return assign(state, { connectionState: action.connectionState });
|
|
|
|
}
|