import 'package:flutter_test/flutter_test.dart';
import 'package:hwhub/utils/reporting_utils.dart';

void main() {
  group('normalizeReportStatus', () {
    test('maps known statuses', () {
      expect(normalizeReportStatus('open'), ReportStatus.open);
      expect(normalizeReportStatus('reviewed'), ReportStatus.reviewed);
      expect(normalizeReportStatus('resolved'), ReportStatus.resolved);
      expect(normalizeReportStatus('dismissed'), ReportStatus.dismissed);
    });

    test('is case-insensitive and defaults unknown to open', () {
      expect(normalizeReportStatus('ReSoLvEd'), ReportStatus.resolved);
      expect(normalizeReportStatus('other'), ReportStatus.open);
      expect(normalizeReportStatus(null), ReportStatus.open);
    });
  });

  group('reportStatusLabel', () {
    test('returns user-facing labels', () {
      expect(reportStatusLabel(ReportStatus.open), 'Open');
      expect(reportStatusLabel(ReportStatus.reviewed), 'Reviewed');
      expect(reportStatusLabel(ReportStatus.resolved), 'Resolved');
      expect(reportStatusLabel(ReportStatus.dismissed), 'Dismissed');
    });
  });

  group('formatReportDateTime', () {
    test('formats timestamp as dd.mm.yyyy hh:mm', () {
      final value = DateTime.utc(2026, 3, 4, 8, 5);
      final formatted = formatReportDateTime(value);
      final local = value.toLocal();
      final expected =
          '${local.day.toString().padLeft(2, '0')}.${local.month.toString().padLeft(2, '0')}.${local.year} ${local.hour.toString().padLeft(2, '0')}:${local.minute.toString().padLeft(2, '0')}';

      expect(formatted, expected);
    });
  });
}
