All files / src/utils filterSummary.js

100% Statements 21/21
91.66% Branches 11/12
100% Functions 2/2
100% Lines 21/21

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 251x 1x 1x 1x 1x 1x 1x   1x   1x 1x 1x   1x 1x 1x 1x 1x 488x 488x 24x 1x 1x  
/**
 * The one line a closed filter panel shows instead of its rows (SB-1714).
 *
 * Mirrors the Android summary (SB-1680): only what is narrowing the list,
 * joined with " · ". A part that is not narrowing anything ("All", no
 * conference picked) is passed as null and dropped.
 */
 
export const SEPARATOR = ' · ';
 
/** Join the non-empty parts. */
export const filterSummary = parts =>
  (parts || []).filter(p => typeof p === 'string' && p.trim()).join(SEPARATOR);
 
/**
 * Name a multi-select: up to `max` names verbatim, then a count.
 * Nothing selected is null — "every conference" narrows nothing.
 */
export const listSummary = (names, noun, max = 2) => {
  const picked = (names || []).filter(Boolean);
  if (picked.length === 0) return null;
  if (picked.length <= max) return picked.join(', ');
  return `${picked.length} ${noun}`;
};