import { describe, expect, it, vi } from 'vitest' import { useAnimatedNumber } from '../use-animated-number' import { formatJackpotNumber } from '#lib/utils' vi.mock('#lib/utils', () => ({ formatJackpotNumber: vi.fn((value, character) => `${value}${character}`), })) describe('useAnimatedNumber', () => { it('should initialize with the correct initial value', () => { const { numberCounter } = useAnimatedNumber(1000) expect(numberCounter.value).toBe('0') }) it('should animate the number to the target value', async () => { const { numberCounter } = useAnimatedNumber(2000) // Simulate the animation completion await new Promise((resolve) => { setTimeout(resolve, 1000) }) expect(numberCounter.value).toBe('0') }) it('should handle changes to the target number', async () => { const { numberCounter } = useAnimatedNumber(1000) // Simulate a change to the target number numberCounter.value = '2000' // Simulate the animation completion await new Promise((resolve) => { setTimeout(resolve, 1000) }) expect(numberCounter.value).toBe('2000') }) it('should format the number correctly', () => { const { numberCounter } = useAnimatedNumber(1000, '.') expect(formatJackpotNumber(1000, '.')).toBe('1000.') }) })