main
 1import 'package:blood_pressure_app/features/input/forms/form_switcher.dart';
 2import 'package:flutter/material.dart';
 3import 'package:flutter_test/flutter_test.dart';
 4import 'package:inline_tab_view/inline_tab_view.dart';
 5
 6void main() {
 7  testWidgets('shows a InlineTabView', (tester) async {
 8    await tester.pumpWidget(MaterialApp(
 9        home: Scaffold(
10            body: FormSwitcher(
11      subForms: [
12        (SizedBox(width: 1, height: 1), SizedBox(width: 2, height: 2))
13      ],
14    ))));
15
16    expect(find.byType(TabBar), findsNothing, reason: 'only one tab present');
17    expect(find.byType(TabBarView), findsNothing);
18    expect(find.byType(InlineTabView), findsNothing, reason: 'only one tab present');
19  });
20
21  testWidgets('shows all passed tabs in TabBar', (tester) async {
22    await tester.pumpWidget(MaterialApp(
23        home: Scaffold(
24            body: FormSwitcher(
25      subForms: [
26        (Text('Tab 1'), SizedBox(width: 2, height: 2)),
27        (Text('Tab 2'), SizedBox(width: 2, height: 2)),
28        (Text('Tab 3'), SizedBox(width: 2, height: 2)),
29        (Text('Tab 4'), SizedBox(width: 2, height: 2)),
30      ],
31    ))));
32
33    expect(find.text('Tab 1'), findsOneWidget);
34    expect(find.text('Tab 2'), findsOneWidget);
35    expect(find.text('Tab 3'), findsOneWidget);
36    expect(find.text('Tab 4'), findsOneWidget);
37  });
38
39  testWidgets('associates title and widget correctly', (tester) async {
40    await tester.pumpWidget(MaterialApp(
41        home: Scaffold(
42            body: FormSwitcher(
43      subForms: [
44        (Text('Tab 1'), Text('Content 1')),
45        (Text('Tab 2'), Text('Content 2')),
46        (Text('Tab 3'), Text('Content 3')),
47        (Text('Tab 4'), Text('Content 4')),
48      ],
49    ))));
50
51    expect(find.text('Content 1'), findsOneWidget);
52    expect(find.text('Content 2'), findsNothing);
53    expect(find.text('Content 3'), findsNothing);
54    expect(find.text('Content 4'), findsNothing);
55
56    await tester.tap(find.text('Tab 2'));
57    await tester.pumpAndSettle();
58
59    expect(find.text('Content 1'), findsNothing);
60    expect(find.text('Content 2'), findsOneWidget);
61    expect(find.text('Content 3'), findsNothing);
62    expect(find.text('Content 4'), findsNothing);
63
64    await tester.tap(find.text('Tab 4'));
65    await tester.pumpAndSettle();
66
67    expect(find.text('Content 1'), findsNothing);
68    expect(find.text('Content 2'), findsNothing);
69    expect(find.text('Content 3'), findsNothing);
70    expect(find.text('Content 4'), findsOneWidget);
71  });
72}