37 lines
1.2 KiB
Dart
37 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:jiffy/jiffy.dart';
|
|
import 'package:marianum_mobile/view/pages/ticker/widgets/ticker_updated_bar.dart';
|
|
|
|
Widget _host(String? publishedAt) =>
|
|
MaterialApp(home: Scaffold(body: TickerUpdatedBar(publishedAt: publishedAt)));
|
|
|
|
void main() {
|
|
setUpAll(() async {
|
|
await Jiffy.setLocale('de');
|
|
});
|
|
|
|
testWidgets('renders the formatted publish date', (tester) async {
|
|
await tester.pumpWidget(_host('2026-02-17T14:30:00'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Aktualisiert am 17.02.2026 14:30'), findsOneWidget);
|
|
expect(find.byIcon(Icons.schedule), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('renders nothing without a date', (tester) async {
|
|
await tester.pumpWidget(_host(null));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byIcon(Icons.schedule), findsNothing);
|
|
expect(find.textContaining('Aktualisiert'), findsNothing);
|
|
});
|
|
|
|
testWidgets('renders nothing for an unparseable date', (tester) async {
|
|
await tester.pumpWidget(_host('not-a-date'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byIcon(Icons.schedule), findsNothing);
|
|
});
|
|
}
|