All files / publisher/pages/Releases/reducers branches.ts

100% Statements 10/10
83.33% Branches 5/6
100% Functions 1/1
100% Lines 10/10

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 25 26 27 28 29 30                      25x   1x 1x 1x   1x     1x 1x 1x 1x     23x      
import { ReleasesReduxState } from "../../../types/releaseTypes";
import {
  OPEN_BRANCHES,
  CLOSE_BRANCHES,
  BranchesAction,
} from "../actions/branches";
 
export default function branches(
  state: ReleasesReduxState["branches"] = [],
  action: BranchesAction
) {
  switch (action.type) {
    case OPEN_BRANCHES: {
      const newState = state.slice(0);
      Eif (!newState.includes(action.payload)) {
        newState.push(action.payload);
      }
      return newState;
    }
    case CLOSE_BRANCHES: {
      const newState = state.slice(0);
      const index = newState.indexOf(action.payload);
      newState.splice(index, 1);
      return newState;
    }
    default:
      return state;
  }
}