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.
29 lines
780 B
JavaScript
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')
|
|
})
|
|
})
|