main
 1import 'package:blood_pressure_app/features/bluetooth/ui/input_card.dart';
 2import 'package:flutter/material.dart';
 3import 'package:flutter_test/flutter_test.dart';
 4
 5void main() {
 6  testWidgets('shows all elements', (WidgetTester tester) async {
 7    await tester.pumpWidget(MaterialApp(
 8      home: InputCard(
 9        onClosed: () {},
10        title: const Text('Some title'),
11        child: const CircularProgressIndicator(),
12      ),
13    ));
14
15    expect(find.text('Some title'), findsOneWidget);
16    expect(find.byType(CircularProgressIndicator), findsOneWidget);
17    expect(find.byIcon(Icons.close), findsOneWidget);
18
19    expect(
20      tester.getBottomLeft(find.text('Some title')).dy,
21      lessThan(tester.getTopLeft(find.byType(CircularProgressIndicator)).dy),
22    );
23    expect(
24      tester.getBottomLeft(find.byIcon(Icons.close)).dy,
25      lessThan(tester.getTopLeft(find.byType(CircularProgressIndicator)).dy),
26    );
27  });
28
29  testWidgets('hides correct elements', (WidgetTester tester) async {
30    await tester.pumpWidget(const MaterialApp(
31      home: InputCard(
32        child: Text('content'),
33      ),
34    ));
35
36    expect(find.text('content'), findsOneWidget);
37    expect(find.byType(CircularProgressIndicator), findsNothing);
38    expect(find.byIcon(Icons.close), findsNothing);
39  });
40
41  testWidgets('triggers close listener', (WidgetTester tester) async {
42    int closeCount = 0;
43    await tester.pumpWidget(MaterialApp(
44      home: InputCard(
45        child: const SizedBox.shrink(),
46        onClosed: () {
47          closeCount++;
48        },
49      ),
50    ));
51
52    expect(find.byIcon(Icons.close), findsOneWidget);
53    await tester.tap(find.byIcon(Icons.close));
54    await tester.pumpAndSettle();
55    expect(closeCount, 1);
56  });
57}