All files / redux/reducers appReducer.ts

87.5% Statements 7/8
66.66% Branches 4/6
100% Functions 1/1
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24      1x             4x   1x   1x   1x   1x 1x        
import {CITIES_DATA, FAVORITE_CITY_DATA, WEATHER_DATA } from '../../data/stub';
import {FETCH_WEATHER_API, RECHERCHER_VILLES, RECUPERER_METEO, RECUPERER_VILLES} from '../constants';
 
const initialState = {
    meteo: WEATHER_DATA,
    villes: CITIES_DATA,
}
 
//@ts-ignore
export default appReducer = (state = initialState, action) => {
    switch (action.type) {
        case FETCH_WEATHER_API:
            return {...state, meteo: action.payload};
        case RECHERCHER_VILLES:
            return {...state, villes: action.payload};
        case RECUPERER_METEO:
            return {...state, meteo: action.payload};
        case RECUPERER_VILLES:
            console.log("================================================================================================="+ action.payload)
            return {...state, villes: action.payload};
        default:
            return state;
    }
}