import 'package:flutter_test/flutter_test.dart';
import 'package:guru_utils/datetime/datetime_utils.dart'; // 请将此路径更改为实际的路径

void main() {
  group('DateTimeUtils', () {
    test('formatLooseDuration with null duration', () {
      expect(DateTimeUtils.formatLooseDuration(null), "-- : -- : --");
    });

    test('formatLooseDuration with less than 1 second', () {
      expect(
          DateTimeUtils.formatLooseDuration(Duration(milliseconds: 500)), "00 : 00 : 00");
    });

    test('formatLooseDuration with only seconds', () {
      expect(DateTimeUtils.formatLooseDuration(Duration(seconds: 45)), "00 : 00 : 45");
    });

    test('formatLooseDuration with only minutes', () {
      expect(DateTimeUtils.formatLooseDuration(Duration(minutes: 15)), "00 : 15 : 00");
    });

    test('formatLooseDuration with hours, minutes and seconds', () {
      expect(
          DateTimeUtils.formatLooseDuration(Duration(hours: 2, minutes: 15, seconds: 45)),
          "02 : 15 : 45");
    });

    test('formatLooseDuration with minimum unit as minute', () {
      expect(
          DateTimeUtils.formatLooseDuration(Duration(minutes: 15, seconds: 45),
              minUnit: TimeUnit.minutes),
          "15 : 45");
    });

    test('formatLooseDuration with minimum unit as second', () {
      expect(
          DateTimeUtils.formatLooseDuration(Duration(seconds: 45),
              minUnit: TimeUnit.seconds),
          "45");
    });
  });
}
