import 'package:flutter_test/flutter_test.dart';
import 'package:jamshalat_masjid_screen/core/enums.dart';
import 'package:jamshalat_masjid_screen/data/local/models.dart';
import 'package:jamshalat_masjid_screen/data/services/hijri_service.dart';

void main() {
  group('PrayerName display labels', () {
    test('uses Jumat label for Friday dzuhur', () {
      expect(
        PrayerName.dzuhur.displayLabel(isFriday: true),
        'JUMAT',
      );
      expect(
        PrayerName.dzuhur.displayLabel(isFriday: false),
        'Dzuhur',
      );
    });

    test('marks fardhu prayers correctly', () {
      expect(PrayerName.subuh.isFardhu, isTrue);
      expect(PrayerName.imsak.isFardhu, isFalse);
    });
  });

  group('AppSettings copyWith', () {
    test('preserves defaults and overrides selected fields', () {
      final settings = AppSettings();
      final updated = settings.copyWith(
        masjidName: 'Masjid Raya',
        cityIdApi: '1301',
        iqomahDzuhur: 12,
      );

      expect(updated.masjidName, 'Masjid Raya');
      expect(updated.cityIdApi, '1301');
      expect(updated.iqomahDzuhur, 12);
      expect(updated.masjidAddress, settings.masjidAddress);
      expect(updated.runningTexts, settings.runningTexts);
    });
  });

  group('HijriCalendarService parsing', () {
    test('extracts hijri label from MyQuran calendar response', () {
      final label = HijriCalendarService.parseHijriLabel({
        'status': true,
        'data': {
          'hijr': {
            'today': 'Senin, 11 Syawal 1447 H',
            'day': 11,
            'monthName': 'Syawal',
            'year': 1447,
          },
        },
      });

      expect(label, '11 Syawal 1447 H');
    });
  });
}
