import 'package:afterwork/core/utils/date_formatter.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:intl/date_symbol_data_local.dart';

void main() {
  setUpAll(() async {
    await initializeDateFormatting('fr_FR', null);
  });
  group('DateFormatter', () {
    test('should format date correctly in French', () {
      // Arrange
      final date = DateTime(2026, 1, 15, 14, 30);

      // Act
      final result = DateFormatter.formatDate(date);

      // Assert
      expect(result, isA<String>());
      expect(result, contains('2026'));
      expect(result, contains('15'));
      expect(result, contains('14:30'));
    });

    test('should format date with different times', () {
      // Arrange
      final morning = DateTime(2026, 1, 15, 9, 0);
      final evening = DateTime(2026, 1, 15, 21, 45);

      // Act
      final morningResult = DateFormatter.formatDate(morning);
      final eveningResult = DateFormatter.formatDate(evening);

      // Assert
      expect(morningResult, contains('09:00'));
      expect(eveningResult, contains('21:45'));
    });

    test('should format date with different days', () {
      // Arrange
      final monday = DateTime(2026, 1, 5); // Monday
      final friday = DateTime(2026, 1, 9); // Friday

      // Act
      final mondayResult = DateFormatter.formatDate(monday);
      final fridayResult = DateFormatter.formatDate(friday);

      // Assert
      expect(mondayResult, isA<String>());
      expect(fridayResult, isA<String>());
      expect(mondayResult, isNot(equals(fridayResult)));
    });

    test('should format date with different months', () {
      // Arrange
      final january = DateTime(2026, 1, 15);
      final december = DateTime(2026, 12, 15);

      // Act
      final janResult = DateFormatter.formatDate(january);
      final decResult = DateFormatter.formatDate(december);

      // Assert
      expect(janResult, contains('janvier'));
      expect(decResult, contains('décembre'));
    });

    test('should format date with different years', () {
      // Arrange
      final date2026 = DateTime(2026, 1, 15);
      final date2027 = DateTime(2027, 1, 15);

      // Act
      final result2026 = DateFormatter.formatDate(date2026);
      final result2027 = DateFormatter.formatDate(date2027);

      // Assert
      expect(result2026, contains('2026'));
      expect(result2027, contains('2027'));
    });

    test('should handle midnight correctly', () {
      // Arrange
      final midnight = DateTime(2026, 1, 15, 0, 0);

      // Act
      final result = DateFormatter.formatDate(midnight);

      // Assert
      expect(result, contains('00:00'));
    });

    test('should handle end of day correctly', () {
      // Arrange
      final endOfDay = DateTime(2026, 1, 15, 23, 59);

      // Act
      final result = DateFormatter.formatDate(endOfDay);

      // Assert
      expect(result, contains('23:59'));
    });
  });
}

