import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:tasq/utils/app_time.dart';

void main() {
  setUp(() {
    // ensure timezone is initialized (no-op if already done)
    AppTime.initialize();
  });

  test('formatDate produces correct string', () {
    final date = DateTime(2025, 1, 5);
    expect(AppTime.formatDate(date), 'Jan 05, 2025');

    final date2 = DateTime(2021, 12, 31);
    expect(AppTime.formatDate(date2), 'Dec 31, 2021');
  });

  test('formatDateRange composes two dates', () {
    final start = DateTime(2023, 3, 1);
    final end = DateTime(2023, 3, 15);
    expect(
      AppTime.formatDateRange(DateTimeRange(start: start, end: end)),
      'Mar 01, 2023 - Mar 15, 2023',
    );

    // identical start/end
    expect(
      AppTime.formatDateRange(DateTimeRange(start: start, end: start)),
      'Mar 01, 2023 - Mar 01, 2023',
    );
  });

  test('formatTime outputs 12-hour clock with suffix', () {
    expect(AppTime.formatTime(DateTime(2020, 1, 1, 0, 0)), '12:00 AM');
    expect(AppTime.formatTime(DateTime(2020, 1, 1, 9, 5)), '09:05 AM');
    expect(AppTime.formatTime(DateTime(2020, 1, 1, 12, 0)), '12:00 PM');
    expect(AppTime.formatTime(DateTime(2020, 1, 1, 23, 59)), '11:59 PM');
  });
}
