A whole bunch of changes
This commit is contained in:
parent
901ec678a3
commit
956231048e
122 changed files with 5442 additions and 914 deletions
68
test/image_source_sheet_test.dart
Normal file
68
test/image_source_sheet_test.dart
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
import 'package:fuel_tax_tracker/widgets/image_source_sheet.dart';
|
||||
|
||||
/// Covers the optional [heading] and [onInfoTap] on [chooseImageSource]'s
|
||||
/// bottom sheet — receipt capture passes "Receipt From" with no info
|
||||
/// button (see receipt_capture.dart); VIN scanning passes "VIN From" plus
|
||||
/// an info button that explains where to find one (see
|
||||
/// add_edit_vehicle_screen.dart).
|
||||
void main() {
|
||||
Future<void> pumpSheet(
|
||||
WidgetTester tester, {
|
||||
String? heading,
|
||||
VoidCallback? onInfoTap,
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Builder(
|
||||
builder: (context) => ElevatedButton(
|
||||
onPressed: () => chooseImageSource(context, heading: heading, onInfoTap: onInfoTap),
|
||||
child: const Text('Open'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text('Open'));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets('shows the heading above Take Photo / Choose from Gallery when provided',
|
||||
(tester) async {
|
||||
await pumpSheet(tester, heading: 'Receipt From');
|
||||
|
||||
expect(find.text('Receipt From'), findsOneWidget);
|
||||
expect(find.text('Take Photo'), findsOneWidget);
|
||||
expect(find.text('Choose from Gallery'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('shows no heading when none is provided', (tester) async {
|
||||
await pumpSheet(tester);
|
||||
|
||||
expect(find.text('Receipt From'), findsNothing);
|
||||
expect(find.text('Take Photo'), findsOneWidget);
|
||||
expect(find.text('Choose from Gallery'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('shows no info button when onInfoTap is omitted, even with a heading',
|
||||
(tester) async {
|
||||
await pumpSheet(tester, heading: 'Receipt From');
|
||||
|
||||
expect(find.byIcon(Icons.info_outline), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('shows an info button next to the heading when onInfoTap is provided, and invokes it',
|
||||
(tester) async {
|
||||
var tapped = false;
|
||||
await pumpSheet(tester, heading: 'VIN From', onInfoTap: () => tapped = true);
|
||||
|
||||
expect(find.text('VIN From'), findsOneWidget);
|
||||
expect(find.byIcon(Icons.info_outline), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byIcon(Icons.info_outline));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(tapped, isTrue);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue