import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/ui/text/relative_time.dart'; void main() { final now = DateTime(2026, 10, 22, 12); test('formats compact past and future list-row times', () { expect(formatRelativeTime(now, now: now), 'just now'); expect( formatRelativeTime(now.subtract(const Duration(minutes: 5)), now: now), '5m', ); expect( formatRelativeTime(now.subtract(const Duration(hours: 3)), now: now), '3h', ); expect( formatRelativeTime(now.subtract(const Duration(days: 3)), now: now), '3d', ); expect( formatRelativeTime(now.subtract(const Duration(days: 8)), now: now), '14 Oct', ); expect( formatRelativeTime(now.add(const Duration(hours: 2)), now: now), 'in 2h', ); }); test('parses timestamps and omits unusable values', () { expect(formatRelativeTimestamp('2026-10-22T11:55:00', now: now), '5m'); expect(formatRelativeTimestamp('', now: now), isNull); expect(formatRelativeTimestamp('not a time', now: now), isNull); }); }