all files / src/reducers/ error.js

100% Statements 8/8
100% Branches 5/5
100% Functions 1/1
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                   140× 35×                     28×          
import {
    TOGGLE_WATCHING_REJECTIONS_FLAG,
    HANDLE_ERROR
} from '../constants/actionTypes.js'
 
const initialState = {
    fatal: null,
    instance: null,
    watchingRejections: null
}
 
const error = (error = initialState, { type, payload }) => {
    switch (type) {
        case HANDLE_ERROR:
            return {
                ...error,
                instance: payload.error,
                fatal: payload.fatal
            }
        case TOGGLE_WATCHING_REJECTIONS_FLAG:
            return {
                ...error,
                watchingRejections: !error.watchingRejections
            }
        default:
            return error
    }
}
 
export default error