All files / src/utils eventLocation.ts

90.9% Statements 10/11
66.66% Branches 4/6
100% Functions 4/4
90% Lines 9/10

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 216x 189x       189x   413x     189x   679x     189x 186x     3x  
export function formatEventLocation(address?: string | null): string {
  Iif (!address) {
    return 'Location not specified';
  }
 
  const parts = address
    .split(',')
    .map((part) => part.trim())
    .filter(Boolean);
 
  const uniqueParts = parts.filter(
    (part, index) =>
      index === parts.findIndex((p) => p.toLowerCase() === part.toLowerCase()),
  );
 
  if (uniqueParts.length >= 2) {
    return `${uniqueParts[0]}, ${uniqueParts[1]}`;
  }
 
  return uniqueParts[0] ?? 'Location not specified';
}