All files / src/actions addResource.js

100% Statements 2/2
100% Branches 0/0
100% Functions 2/2
100% Lines 2/2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                          3x   3x    
import ActionFactory from "../ActionFactory";
import * as types from "../constants/ActionTypes";
 
/**
 * The addResource action uses the ActionFactory to fetch a reource, and puts it
 * on the `horsemanResources` key in state.
 *
 * @param {string} endpoint The endpoint to fetch and put into state, the
 *                          endpoint will also be used as the key within the
 *                          `horsemanResources` state
 *                          location.
 */
export default endpoint =>
  ActionFactory(
    types.ADD_RESOURCE,
    state => typeof state.horsemanResources[endpoint] !== "undefined",
  )(endpoint);