profileShare

rasmusjy / splitapp-frontend-vue

Read-only snapshot

No repository description.

main default branch 96 files Expires Sep 13, 2026, 9:06 AM
formatCurrency.spec.ts 1,070 bytes
1 import { describe, it, expect } from 'vitest'
2 import { formatCurrency } from '@/utils/formatCurrency'
3
4 describe('formatCurrency', () => {
5 it('formats a positive number with default 2 decimals and no symbol', () => {
6 expect(formatCurrency(1234.5)).toBe('1,234.50')
7 })
8
9 it('prefixes the currency symbol when provided', () => {
10 expect(formatCurrency(99.5, '€')).toBe('€99.50')
11 expect(formatCurrency(10, '$')).toBe('$10.00')
12 })
13
14 it('handles zero', () => {
15 expect(formatCurrency(0, '€')).toBe('€0.00')
16 })
17
18 it('handles negative numbers — sign goes before the symbol', () => {
19 expect(formatCurrency(-42.5, '€')).toBe('-€42.50')
20 })
21
22 it('respects custom decimal count', () => {
23 expect(formatCurrency(10, '$', 0)).toBe('$10')
24 expect(formatCurrency(10.12345, '$', 4)).toBe('$10.1235')
25 })
26
27 it('ignores null symbol', () => {
28 expect(formatCurrency(5.25, null)).toBe('5.25')
29 })
30
31 it('uses thousands separators for large amounts', () => {
32 expect(formatCurrency(1_234_567.89, '$')).toBe('$1,234,567.89')
33 })
34 })
35