41 lines
1.2 KiB
Dart
41 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/motion/motion.dart';
|
|
|
|
Widget _list(List<String> ids, {bool reduce = false}) => Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: MediaQuery(
|
|
data: MediaQueryData(disableAnimations: reduce),
|
|
child: ArrivalScope(
|
|
ids: ids,
|
|
child: Column(
|
|
children: [
|
|
for (final id in ids)
|
|
Arrival(key: ValueKey(id), id: id, child: Text(id)),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
Finder _fadeOf(String id) =>
|
|
find.ancestor(of: find.text(id), matching: find.byType(FadeTransition));
|
|
|
|
void main() {
|
|
testWidgets('only items after the first load fade in', (tester) async {
|
|
await tester.pumpWidget(_list(['a', 'b']));
|
|
expect(_fadeOf('a'), findsNothing);
|
|
|
|
await tester.pumpWidget(_list(['c', 'a', 'b']));
|
|
expect(_fadeOf('c'), findsOneWidget);
|
|
expect(_fadeOf('a'), findsNothing);
|
|
await tester.pumpAndSettle();
|
|
});
|
|
|
|
testWidgets('reduced motion shows arrivals at once', (tester) async {
|
|
await tester.pumpWidget(_list(['a'], reduce: true));
|
|
await tester.pumpWidget(_list(['b', 'a'], reduce: true));
|
|
expect(_fadeOf('b'), findsNothing);
|
|
});
|
|
}
|