Files
crypto_trading/frontend/src/format.test.js
T
matitos 9c3bee87ac
CI/CD / backend (push) Successful in 5m18s
CI/CD / frontend (push) Successful in 5m2s
CI/CD / build (push) Successful in 34s
CI/CD / cleanup (push) Successful in 6s
CI/CD / deploy (push) Successful in 22s
Crypto trading bot: engine, brokers, backtester, dashboard, deploy
FastAPI backend with a single-strategy async engine, paper and Binance
brokers, pure-python indicators, a backtester that shares the engine's
portfolio math, and a Vue dashboard with a live WebSocket feed. Adds the
Gitea Actions CI/CD workflow that deploys to Traefik via docker_default.
2026-09-18 17:02:33 +00:00

29 lines
780 B
JavaScript

import { describe, expect, it } from 'vitest'
import { fmtMoney, fmtPrice, pnlClass, signed } from './format'
describe('format helpers', () => {
it('formats money with two decimals', () => {
expect(fmtMoney(10000)).toBe('10,000.00')
})
it('handles null', () => {
expect(fmtMoney(null)).toBe('—')
expect(fmtPrice(undefined)).toBe('—')
})
it('formats small prices with six decimals', () => {
expect(fmtPrice(0.5)).toBe('0.500000')
})
it('signs positive values', () => {
expect(signed(12.346)).toBe('+12.35')
expect(signed(-3)).toBe('-3.00')
})
it('classifies pnl colour', () => {
expect(pnlClass(5)).toBe('text-emerald-400')
expect(pnlClass(-5)).toBe('text-rose-400')
expect(pnlClass(0)).toBe('text-slate-300')
})
})