46 lines
1.5 KiB
Dart
46 lines
1.5 KiB
Dart
|
|
import 'package:flutter_test/flutter_test.dart';
|
|||
|
|
import 'package:halkyon_ui/halkyon_ui.dart';
|
|||
|
|
import 'package:material_ui/material_ui.dart';
|
|||
|
|
|
|||
|
|
void main() {
|
|||
|
|
Future<void> show(WidgetTester tester, {bool still = false}) =>
|
|||
|
|
tester.pumpWidget(
|
|||
|
|
MaterialApp(
|
|||
|
|
theme: appTheme(Brightness.light),
|
|||
|
|
home: MediaQuery(
|
|||
|
|
data: MediaQueryData(disableAnimations: still),
|
|||
|
|
child: const Scaffold(
|
|||
|
|
body: Shimmer(
|
|||
|
|
child: Column(
|
|||
|
|
children: [
|
|||
|
|
SkeletonBox(width: 120, height: 18),
|
|||
|
|
SkeletonBox(height: 12),
|
|||
|
|
],
|
|||
|
|
),
|
|||
|
|
),
|
|||
|
|
),
|
|||
|
|
),
|
|||
|
|
),
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
testWidgets('a skeleton stands where content will, in the theme’s '
|
|||
|
|
'muted colour, a light band sweeping across it', (tester) async {
|
|||
|
|
await show(tester);
|
|||
|
|
|
|||
|
|
expect(tester.getSize(find.byType(SkeletonBox).first), const Size(120, 18));
|
|||
|
|
expect(find.byType(ShaderMask), findsOneWidget);
|
|||
|
|
expect(tester.hasRunningAnimations, isTrue);
|
|||
|
|
await tester.pump(const Duration(seconds: 1));
|
|||
|
|
expect(tester.hasRunningAnimations, isTrue, reason: 'sweeping on');
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
testWidgets('it stands still where the system asks for no animations', (
|
|||
|
|
tester,
|
|||
|
|
) async {
|
|||
|
|
await show(tester, still: true);
|
|||
|
|
|
|||
|
|
expect(find.byType(SkeletonBox), findsNWidgets(2));
|
|||
|
|
expect(find.byType(ShaderMask), findsNothing);
|
|||
|
|
expect(tester.hasRunningAnimations, isFalse);
|
|||
|
|
});
|
|||
|
|
}
|