test: юнит-тесты на форматирование и разбивки крипто-портфеля + версия 1.1.6

Vitest для чистой логики: lib/format.ts (заодно поймал баг в
trimTrailingZeros на "-0.000") и расчёт разбивки по риску/монете/сети
на вкладке Crypto — вынес их из компонентов в отдельные тестируемые
функции. Тесты подключены в CI. Версия приложения обновлена до 1.1.6.
This commit is contained in:
ZProger
2026-09-09 00:52:27 +03:00
parent c3047c6d6a
commit f5c6591310
13 changed files with 1279 additions and 39 deletions

View File

@@ -26,7 +26,7 @@ const SERIES_COLORS = [
const OTHER_COLOR = "var(--series-other)";
const MAX_SLICES = SERIES_COLORS.length;
interface Slice {
export interface Slice {
key: string;
name: string;
symbol: string | null;
@@ -34,7 +34,9 @@ interface Slice {
color: string;
}
function buildSlices(holdings: CryptoHolding[]): Slice[] {
// Exported for direct unit testing (see CryptoAllocationBody.test.ts) —
// the donut/table JSX below isn't worth rendering just to check the math.
export function buildSlices(holdings: CryptoHolding[]): Slice[] {
const priced = holdings
.filter((h) => h.value !== null && Number(h.value) > 0)
.map((h) => ({ key: String(h.asset_id), name: h.name, symbol: h.symbol, amount: Number(h.value) }))