import formatters from './formatters';

/**
 * Get a contest's electoral votes from the contest's ID.
 *
 * @param {ContestSummaryResuts} summary
 *   The summary-level results of the contest for which we want the electoral votes
 * @param {Object} [options]
 *   Additional configuration options:
 *   - `format`: The format of the output (either `number-only`, `short` or `long`)
 * @returns {string}
 */
const getContestElectoralVotes = function getContestElectoralVotes(summary, options = {}) {
  const {
    format = 'long'
  } = options;
  const formatter = formatters[format];
  const num = summary.evs;
  if (!num) {
    return undefined;
  }
  return formatter(num);
};
export default getContestElectoralVotes;