import { describe, it, expect } from 'vitest' import { formatDayCount, formatPercentage } from '@/utils/formatting' describe('formatting.ts utilities', () => { describe('formatDayCount', () => { it('returns singular form for 1 day', () => { expect(formatDayCount(1)).toBe('1 dag') }) it('returns plural form for 0 days', () => { expect(formatDayCount(0)).toBe('0 dagar') }) it('returns plural form for 2 days', () => { expect(formatDayCount(2)).toBe('2 dagar') }) it('returns plural form for many days', () => { expect(formatDayCount(25)).toBe('25 dagar') expect(formatDayCount(365)).toBe('365 dagar') }) it('handles large numbers', () => { expect(formatDayCount(1000)).toBe('1000 dagar') }) }) describe('formatPercentage', () => { it('formats simple percentage', () => { expect(formatPercentage(1, 4)).toBe('25%') }) it('rounds to nearest integer', () => { expect(formatPercentage(1, 3)).toBe('33%') // 33.333...% expect(formatPercentage(2, 3)).toBe('67%') // 66.666...% }) it('handles 0% correctly', () => { expect(formatPercentage(0, 10)).toBe('0%') }) it('handles 100% correctly', () => { expect(formatPercentage(10, 10)).toBe('100%') }) it('returns 0% when denominator is 0', () => { expect(formatPercentage(5, 0)).toBe('0%') }) it('handles fractional results with proper rounding', () => { expect(formatPercentage(1, 2)).toBe('50%') expect(formatPercentage(3, 4)).toBe('75%') }) it('works with large numbers', () => { expect(formatPercentage(500, 1000)).toBe('50%') }) }) })