flutter_sticky_headers icon indicating copy to clipboard operation
flutter_sticky_headers copied to clipboard

adding tests to StickyHeader and StickyHeaderWidgetBuilder

Open henriquezanfa opened this issue 1 year ago • 0 comments

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

henriquezanfa avatar Dec 31 '23 11:12 henriquezanfa