flutter_sticky_headers
flutter_sticky_headers copied to clipboard
adding tests to StickyHeader and StickyHeaderWidgetBuilder
I want to make it safer to add new features/change the current code. I started adding some tests so we can guarantee that the current state is not lost.
I had trouble validating the stuckAmount on StickyHeaderWidgetBuilder. If someone knows how to properly test it it would be great. What I tried was the following:
...
ListView.builder(
itemCount: 100,
itemBuilder: (context, index) {
return StickyHeaderBuilder(
builder: (context, stuckAmount) {
capturedStuckAmount = stuckAmount;
return SizedBox(
height: 50.0,
child: Text('Header #$index'),
);
},
content: SizedBox(
height: 200.0,
child: Text('Content #$index'),
),
);
},
),
...
await tester.drag(find.byType(ListView), const Offset(0.0, -25.0));
await tester.pumpAndSettle();
expect(capturedStuckAmount, -0.5);
but the capturedStuckAmount was now what I expected, I don't know if it is something with tester.drag that I'm not aware of.
Anyway, the other tests are working