All files / app/assets/javascripts/pages/admin/application_settings utils.js

100% Statements 5/5
40% Branches 2/5
100% Functions 2/2
100% Lines 5/5

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                    1x 1x   1x 19x         1x    
import { includes } from 'lodash';
import { parseBoolean } from '~/lib/utils/common_utils';
 
/**
 * Returns a new dataset that has all the values of keys indicated in
 * booleanAttributes transformed by the parseBoolean() helper function
 *
 * @param {Object}
 * @returns {Object}
 */
export const getParsedDataset = ({ dataset = {}, booleanAttributes = [] } = {}) => {
  const parsedDataset = {};
 
  Object.keys(dataset).forEach((key) => {
    parsedDataset[key] = includes(booleanAttributes, key)
      ? parseBoolean(dataset[key])
      : dataset[key];
  });
 
  return parsedDataset;
};