48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fruitshorts/core/widgets/drama_grid_skeleton.dart';
|
|
|
|
void main() {
|
|
testWidgets('renders one local shimmer mask per skeleton card', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 1000);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
|
|
await tester.pumpWidget(
|
|
const MaterialApp(
|
|
home: Scaffold(
|
|
body: DramaGridSkeleton(
|
|
columns: 3,
|
|
horizontalPadding: 14,
|
|
crossAxisSpacing: 8,
|
|
mainAxisSpacing: 12,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump(const Duration(milliseconds: 100));
|
|
|
|
expect(find.byType(GridView), findsOneWidget);
|
|
expect(
|
|
find.ancestor(
|
|
of: find.byType(GridView),
|
|
matching: find.byType(ShaderMask),
|
|
),
|
|
findsNothing,
|
|
);
|
|
for (var index = 0; index < 9; index++) {
|
|
final card = find.byKey(Key('drama-grid-skeleton-$index'));
|
|
expect(card, findsOneWidget);
|
|
expect(
|
|
find.ancestor(of: card, matching: find.byType(ShaderMask)),
|
|
findsOneWidget,
|
|
);
|
|
}
|
|
});
|
|
}
|