22 lines
1.0 KiB
TypeScript
22 lines
1.0 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { formatPeerMetric, peerMetricLabel } from './peer-metrics';
|
|
|
|
describe('peer metric presentation', () => {
|
|
it('formats timing medians in milliseconds instead of percent', () => {
|
|
expect(formatPeerMetric('init_time_ms_p50', '1240')).toBe('۱٬۲۴۰ میلیثانیه');
|
|
expect(formatPeerMetric('verify_time_ms_p95', '980')).toBe('۹۸۰ میلیثانیه');
|
|
});
|
|
|
|
it('formats rate medians as percentages', () => {
|
|
expect(formatPeerMetric('payment_success_rate', '87.25')).toBe('۸۷٫۲۵٪');
|
|
expect(formatPeerMetric('paid_fee_rate', '0.5')).toBe('۰٫۵٪');
|
|
});
|
|
|
|
it('provides Persian labels for every contracted peer metric', () => {
|
|
expect(peerMetricLabel('payment_success_rate')).toBe('نرخ موفقیت پرداخت');
|
|
expect(peerMetricLabel('init_time_ms_p95')).toBe('زمان آغاز پرداخت — صدک ۹۵');
|
|
expect(peerMetricLabel('verify_time_ms_p50')).toBe('زمان تأیید — میانه');
|
|
});
|
|
});
|