test: mock AnthropicClient in analyze tests to prevent live API calls
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Number and currency formatting utilities.
|
||||
*/
|
||||
|
||||
/** Formats a P/E ratio — e.g. 22.5 → "22.5x", null → "—" */
|
||||
export function fmtPE(v: number | null | undefined): string {
|
||||
return v != null ? v + 'x' : '—';
|
||||
}
|
||||
|
||||
/** Full currency format — e.g. 1234.5 → "$1,234.50" */
|
||||
export function fmt(n: number | null | undefined): string {
|
||||
return n != null
|
||||
? new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(n)
|
||||
: '—';
|
||||
}
|
||||
|
||||
/** Compact currency format (no cents) — e.g. 1234.5 → "$1,235" */
|
||||
export function fmtShort(n: number | null | undefined): string {
|
||||
return n != null
|
||||
? new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
maximumFractionDigits: 0,
|
||||
}).format(n)
|
||||
: '—';
|
||||
}
|
||||
Reference in New Issue
Block a user