fix(subspecies): allows for custom subspecies names
This commit is contained in:
parent
25968533ab
commit
7ccfda5d17
2 changed files with 6 additions and 1 deletions
|
|
@ -101,6 +101,11 @@ describe('formatFieldOutput', () => {
|
||||||
expect(formatFieldOutput(field, 'hharar', stubSpecies, 'tajara')).toBe('Ethnicity: Hharar');
|
expect(formatFieldOutput(field, 'hharar', stubSpecies, 'tajara')).toBe('Ethnicity: Hharar');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('formats custom subspecies with dynamic label', () => {
|
||||||
|
const field: FieldDef = { label: 'Subspecies', type: 'subspecies' };
|
||||||
|
expect(formatFieldOutput(field, 'asdfg', stubSpecies, 'tajara')).toBe('Ethnicity: asdfg');
|
||||||
|
});
|
||||||
|
|
||||||
it('returns null for empty subspecies', () => {
|
it('returns null for empty subspecies', () => {
|
||||||
const field: FieldDef = { label: 'Subspecies', type: 'subspecies' };
|
const field: FieldDef = { label: 'Subspecies', type: 'subspecies' };
|
||||||
expect(formatFieldOutput(field, '', stubSpecies, 'tajara')).toBeNull();
|
expect(formatFieldOutput(field, '', stubSpecies, 'tajara')).toBeNull();
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ export function formatFieldOutput(
|
||||||
const sp = speciesData.find((s) => s.id === currentSpecies);
|
const sp = speciesData.find((s) => s.id === currentSpecies);
|
||||||
if (!sp) return null;
|
if (!sp) return null;
|
||||||
const sub = sp.subspecies.find((s) => s.id === value);
|
const sub = sp.subspecies.find((s) => s.id === value);
|
||||||
return sub ? `${sp.subspeciesLabel}: ${sub.name}` : null;
|
return sub ? `${sp.subspeciesLabel}: ${sub.name}` : `${sp.subspeciesLabel}: ${value}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'languages': {
|
case 'languages': {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue