42 lines
1.4 KiB
Dart
42 lines
1.4 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fruitshorts/core/formatting/localized_date_time.dart';
|
|
import 'package:fruitshorts/l10n/app_localizations.dart';
|
|
|
|
void main() {
|
|
testWidgets(
|
|
'should_use_indonesian_material_date_and_time_when_locale_is_id',
|
|
(tester) async {
|
|
final value = DateTime(2026, 10, 17, 12, 30);
|
|
late String formatted;
|
|
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
locale: const Locale('id'),
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: Builder(
|
|
builder: (context) {
|
|
formatted = formatLocalizedDateTime(context, value);
|
|
final localizations = MaterialLocalizations.of(context);
|
|
final expectedDate = localizations.formatCompactDate(
|
|
value.toLocal(),
|
|
);
|
|
final expectedTime = localizations.formatTimeOfDay(
|
|
TimeOfDay.fromDateTime(value.toLocal()),
|
|
alwaysUse24HourFormat: MediaQuery.alwaysUse24HourFormatOf(
|
|
context,
|
|
),
|
|
);
|
|
expect(formatted, '$expectedDate $expectedTime');
|
|
return const SizedBox.shrink();
|
|
},
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|