All files / src/utils renamedFields.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 3/3
100% Lines 3/3

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                          3x 4x 4x    
/**
 * A field the API renamed on import or fork because an earlier field of the
 * entity had its name in that language (flows-api utils/fieldNameUniqueness.js).
 */
export interface RenamedField {
  fieldId: string
  language: string
  from: string
  to: string
}
 
/** "2 field(s) renamed, their name being taken: Price → Price (2), ..." */
export function renamedFieldsText(t: (key: string) => string, renamed: RenamedField[]): string {
  return t('entity.importResultRenamedFields')
    .replace('{count}', String(new Set(renamed.map((r) => r.fieldId)).size))
    .replace('{names}', renamed.map((r) => `${r.from} → ${r.to}`).join(', '))
}