Files
aurum/frontend/src/test/cryptoFixtures.ts
ZProger f5c6591310 test: юнит-тесты на форматирование и разбивки крипто-портфеля + версия 1.1.6
Vitest для чистой логики: lib/format.ts (заодно поймал баг в
trimTrailingZeros на "-0.000") и расчёт разбивки по риску/монете/сети
на вкладке Crypto — вынес их из компонентов в отдельные тестируемые
функции. Тесты подключены в CI. Версия приложения обновлена до 1.1.6.
2026-09-09 00:52:27 +03:00

34 lines
940 B
TypeScript

import type { CryptoHolding } from "@/types";
let nextAssetId = 1;
/** Minimal valid CryptoHolding for allocation-math tests — every field the
* type requires, with sane defaults so a test only has to override what it
* actually cares about (symbol, value, risk_level, network, ...). */
export function makeHolding(overrides: Partial<CryptoHolding> = {}): CryptoHolding {
const id = overrides.asset_id ?? nextAssetId++;
return {
asset_id: id,
portfolio_id: 1,
coingecko_id: `coin-${id}`,
symbol: `C${id}`,
name: `Coin ${id}`,
thumb_url: null,
risk_level: "high",
network: null,
quantity: "1",
avg_buy_price: "1",
current_price: "1",
price_change_1h: null,
price_change_24h: null,
price_change_7d: null,
price_change_30d: null,
price_change_1y: null,
value: "100",
cost_basis: "100",
profit_loss: "0",
profit_loss_percent: 0,
...overrides,
};
}