All files / nexshop-web-contents/src/reducer popup.js

100% Statements 8/8
100% Branches 8/8
100% Functions 1/1
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 181x   1x     7x   7x   4x   4x   1x   2x    
import {CLOSE_POPUP, OPEN_POPUP} from "../action/popup";
 
const initialState = {name: ''};
 
export function popup(state = initialState, action) {
    const {type, name, position} = action;
 
    switch (type) {
        case OPEN_POPUP:
            let nextState = name ? Object.assign({}, state, {name: name}) : Object.assign({}, state, initialState);
 
            return position ? {...nextState, position} : nextState;
        case CLOSE_POPUP:
            return '';
        default:
            return state;
    }
}