main
1import 'package:blood_pressure_app/features/settings/tiles/titled_column.dart';
2import 'package:flutter/material.dart';
3import 'package:flutter_test/flutter_test.dart';
4
5import '../../../util.dart';
6
7void main() {
8 testWidgets('should show title and widgets', (tester) async {
9 await tester.pumpWidget(materialApp(TitledColumn(
10 title: const Text('test title'),
11 children: [
12 const ListTile(title: Text('ListTile text 1'),),
13 SwitchListTile(
14 title: const Text('SwitchListTile text'),
15 value: true, onChanged: (v) {},),
16 const ListTile(title: Text('ListTile text 2'),),
17 ],
18 ),),);
19 expect(tester.takeException(), isNull);
20
21 expect(find.text('test title'), findsOneWidget);
22 expect(find.text('ListTile text 1'), findsOneWidget);
23 expect(find.text('SwitchListTile text'), findsOneWidget);
24 expect(find.text('ListTile text 2'), findsOneWidget);
25 });
26 testWidgets('should show title first', (tester) async {
27 await tester.pumpWidget(materialApp(TitledColumn(
28 title: const Text('test title'),
29 children: [
30 const ListTile(title: Text('ListTile text 1'),),
31 SwitchListTile(
32 title: const Text('SwitchListTile text'),
33 value: true, onChanged: (v) {},),
34 const ListTile(title: Text('ListTile text 2'),),
35 ],
36 ),),);
37
38 expect(find.byType(Column), findsOneWidget);
39 expect(find.descendant(
40 of: find.byType(Column).first,
41 matching: find.text('test title'),),
42 findsOneWidget,
43 );
44 });
45}