Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
function formatDistributionFrequency(value: unknown): string {
const raw = String(value ?? '').trim();
const normalized = raw.toLowerCase().replace(/[‐‑‒–—]/g, '-').replace(/\s+/g, ' ');
if (!normalized || normalized === '-' || normalized === '—') return '00 - —';
if (!normalized || normalized === '-' || normalized === '—') return '00 - None';
if (normalized === 'monthly') return '01 - Monthly';
if (normalized === 'quarterly') return '04 - Quarterly';
if (normalized === 'semiannually' || normalized === 'semi-annually' || normalized === 'semi-annual' || normalized === 'semiannual') return '06 - Semi-annually';
Expand Down Expand Up @@ -1172,7 +1172,7 @@
<td class="py-2.5 px-4 text-right font-mono text-slate-700 dark:text-slate-300">${escapeHtml(fund.ter || '—')}</td>
<td class="py-2.5 px-4 text-right font-mono text-slate-700 dark:text-slate-300">${formatPercent(fund.dividendYield)}</td>
<td class="py-2.5 px-4 text-right font-mono text-slate-700 dark:text-slate-300">—</td>
<td class="py-2.5 px-4 text-slate-600 dark:text-slate-300 font-mono">${escapeHtml(fund.frequencyCode || '00 - —')}</td>
<td class="py-2.5 px-4 text-slate-600 dark:text-slate-300 font-mono">${escapeHtml(fund.frequencyCode || '00 - None')}</td>
<td class="py-2.5 px-4 text-right font-mono text-slate-700 dark:text-slate-300">${formatPercent(fund.ytd)}</td>
<td class="py-2.5 px-4 text-right font-mono text-slate-700 dark:text-slate-300">${formatPercent(fund.yr1)}</td>
<td class="py-2.5 px-4 text-right font-mono text-slate-700 dark:text-slate-300">${formatPercent(fund.tr3y)}</td>
Expand Down
35 changes: 28 additions & 7 deletions scripts/update-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -930,13 +930,13 @@ describe('formatDistributionFrequency (catalog Frequency column)', () => {
expect(formatDistributionFrequency('monthly')).toBe('01 - Monthly');
});

test('treats missing data as "00 - —" instead of dropping the cell', () => {
expect(formatDistributionFrequency(undefined)).toBe('00 - —');
expect(formatDistributionFrequency(null)).toBe('00 - —');
expect(formatDistributionFrequency('')).toBe('00 - —');
expect(formatDistributionFrequency(' ')).toBe('00 - —');
expect(formatDistributionFrequency('-')).toBe('00 - —');
expect(formatDistributionFrequency('—')).toBe('00 - —');
test('treats missing data as "00 - None" instead of dropping the cell', () => {
expect(formatDistributionFrequency(undefined)).toBe('00 - None');
expect(formatDistributionFrequency(null)).toBe('00 - None');
expect(formatDistributionFrequency('')).toBe('00 - None');
expect(formatDistributionFrequency(' ')).toBe('00 - None');
expect(formatDistributionFrequency('-')).toBe('00 - None');
expect(formatDistributionFrequency('—')).toBe('00 - None');
});

test('passes an unknown published value through unchanged', () => {
Expand All @@ -950,3 +950,24 @@ describe('formatDistributionFrequency (catalog Frequency column)', () => {
expect(codes).toEqual(['00 - None', '01 - Monthly', '04 - Quarterly', '06 - Semi-annually', '12 - Annually', '99 - Irregular']);
});
});


import { test as frequencyLabelTest, expect as frequencyLabelExpect } from 'bun:test';
frequencyLabelTest('Frequency placeholders display None and existing cadence labels stay unchanged', async () => {
const text = await Bun.file(new URL('../app.tsx', import.meta.url)).text();
const start = /^([ \t]*)function (formatDividendFrequency|formatDistributionFrequency)\(/m.exec(text);
frequencyLabelExpect(start).not.toBeNull();
const tail = text.slice(start!.index);
const end = new RegExp('^' + start![1] + '\u007d', 'm').exec(tail);
frequencyLabelExpect(end).not.toBeNull();
const js = new Bun.Transpiler({ loader: 'ts' }).transformSync(tail.slice(0, end!.index + end![0].length));
const format = new Function(js + '; return ' + start![2] + ';')();
for (const value of [null, undefined, '', ' ', '-', '‐', '‑', '‒', '–', '—', ' — ']) {
frequencyLabelExpect(format(value)).toBe('00 - None');
}
for (const [input, expected] of [
['None', '00 - None'], ['Unknown', '00 - Unknown'], ['Monthly', '01 - Monthly'],
['Quarterly', '04 - Quarterly'], ['Semi-annually', '06 - Semi-annually'],
['Annually', '12 - Annually'], ['Irregular', '99 - Irregular'],
]) frequencyLabelExpect(format(input)).toBe(expected);
});