import 'package:flutter_test/flutter_test.dart'; import 'package:health_app/pages/medication/medication_ui_logic.dart'; void main() { test('medication list dates omit the current year', () { final now = DateTime(2026, 7, 14); expect(formatMedicationPeriod('2026-07-14', null, now: now), '07.14 - 长期'); expect( formatMedicationPeriod('2026-07-13', '2026-07-14', now: now), '07.13 - 07.14', ); }); test('medication list dates keep years when the range crosses years', () { expect( formatMedicationPeriod( '2026-12-20', '2027-01-15', now: DateTime(2026, 7, 14), ), '2026.12.20 - 2027.01.15', ); }); test('form dates use hyphens and keep the year', () { expect(formatMedicationFormDate(DateTime(2026, 7, 14)), '2026-07-14'); }); }