28 lines
1.1 KiB
Dart
28 lines
1.1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:immich_mobile/extensions/datetime_extensions.dart';
|
|
import 'package:intl/date_symbol_data_local.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
void main() {
|
|
final originalLocale = Intl.defaultLocale;
|
|
setUpAll(initializeDateFormatting);
|
|
tearDown(() => Intl.defaultLocale = originalLocale);
|
|
|
|
test('date and time helpers fall back for an unsupported locale', () {
|
|
Intl.defaultLocale = 'mi';
|
|
final date = DateTime(2023, 8, 28, 13, 45);
|
|
expect(resolvedDateTimeLocale(), 'en_US');
|
|
expect(date.formatDate(), 'Aug 28, 2023');
|
|
expect(date.formatTime(alwaysUse24HourFormat: true), '13:45');
|
|
expect(DateRangeFormatting.formatDateRange(date, DateTime(2023, 8, 29)), 'Aug 28 - Aug 29, 2023');
|
|
});
|
|
|
|
test('supported Russian formatting is preserved', () {
|
|
Intl.defaultLocale = 'ru';
|
|
final date = DateTime(2023, 8, 28, 13, 45);
|
|
expect(resolvedDateTimeLocale(), 'ru');
|
|
expect(date.formatDate(), DateFormat.yMMMd('ru').format(date));
|
|
expect(date.formatTime(alwaysUse24HourFormat: true), '13:45');
|
|
});
|
|
}
|