import 'package:flutter_test/flutter_test.dart';
import 'package:social_app/features/calendar/ui/calendar_time_utils.dart';

void main() {
  group('calendar_time_utils', () {
    test('returns week start on sunday', () {
      final date = DateTime(2026, 2, 11);
      final weekStart = weekStartFor(date);

      expect(weekStart.year, 2026);
      expect(weekStart.month, 2);
      expect(weekStart.day, 8);
    });

    test('shows current marker only for selected today', () {
      final now = DateTime(2026, 2, 11, 15, 28);

      expect(shouldShowCurrentMarker(DateTime(2026, 2, 11), now), isTrue);
      expect(shouldShowCurrentMarker(DateTime(2026, 2, 10), now), isFalse);
    });

    test('formats hour minute with zero pad', () {
      expect(formatHm(DateTime(2026, 2, 11, 7, 5)), '07:05');
      expect(formatHm(DateTime(2026, 2, 11, 15, 28)), '15:28');
    });

    test('parses and formats ymd date string', () {
      final parsed = parseYmd('2026-02-11');

      expect(parsed, isNotNull);
      expect(parsed!.year, 2026);
      expect(parsed.month, 2);
      expect(parsed.day, 11);
      expect(formatYmd(parsed), '2026-02-11');
    });

    test('returns null for invalid ymd date string', () {
      expect(parseYmd('2026/02/11'), isNull);
      expect(parseYmd('bad-input'), isNull);
      expect(parseYmd(null), isNull);
    });

    test('builds all dates for month', () {
      final dates = monthDatesFor(DateTime(2026, 2, 9));

      expect(dates.length, 28);
      expect(formatYmd(dates.first), '2026-02-01');
      expect(formatYmd(dates.last), '2026-02-28');
    });
  });
}
