all files / src/redux/reducers/ progress.js

58.33% Statements 14/24
50% Branches 8/16
100% Functions 2/2
80% Lines 12/15
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 32 33 34 35 36 37 38 39 40 41 42 43                          65× 65×   65×                             65×      
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.initialState = undefined;
exports.default = progressReducer;
 
var _progress = require('../actions/progress');
 
var Actions = _interopRequireWildcard(_progress);
 
function _interopRequireWildcard(obj) { Eif (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
 
var initialState = exports.initialState = {
  current: 0,
  total: null,
  progressReset: false
};
 
function progressReducer() {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
  var action = arguments[1];
 
  switch (action.type) {
    case Actions.SETUP_PROGRESS:
      {
        return { current: 0, total: action.total };
      }
    case Actions.ON_SOME_PROGRESS:
      {
        return Object.assign({}, state, { current: action.current });
      }
    case Actions.RESET_PROGRESS:
      {
        return { current: 0, total: null, progressReset: action.val };
      }
 
    default:
      return state;
  }
}