import { describe, expect, it } from 'vitest'; import { excerpt, formatEngineSize, formatMileage, formatPower, formatPrice, slugifyCar } from '../src/lib/format'; describe('Lithuanian listing formatters', () => { it('formats prices with spaces and a non-breaking euro separator', () => { expect(formatPrice(12500)).toBe('12 500\u00a0€'); }); it('formats mileage with grouped spaces', () => { expect(formatMileage(145000)).toBe('145 000 km'); }); it('formats power in kW and AG', () => { expect(formatPower(140)).toBe('140 kW (190 AG)'); }); it('formats engine size with a Lithuanian decimal separator', () => { expect(formatEngineSize(2.5)).toBe('2,5 l'); }); it('creates ascii car slugs from Lithuanian city names', () => { expect(slugifyCar({ make: 'Škoda', model: 'Octavia RS', year: 2020, city: 'Šiauliai' })).toBe( 'skoda-octavia-rs-2020-siauliai', ); }); it('creates plain text excerpts capped at 155 characters', () => { const text = '**Patikrintas automobilis.** '.repeat(12); expect(excerpt(text)).toHaveLength(155); expect(excerpt(text)).not.toContain('*'); }); });