Skip to content

Commit

Permalink
update tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan-tbd committed Jul 19, 2024
1 parent 05bd66c commit 9aed8e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion test/features/home/home_page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void main() async {

expect(find.text('No transactions yet'), findsOneWidget);
expect(
find.text('Start by adding funds to your account!'),
find.text('Start by sending money through your PFI!'),
findsOneWidget,
);
expect(find.text('Get started'), findsOneWidget);
Expand Down
40 changes: 18 additions & 22 deletions test/shared/json_schema_form_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:didpay/features/payment/payment_details_state.dart';
import 'package:didpay/features/payment/payment_method.dart';
import 'package:didpay/shared/json_schema_form.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down Expand Up @@ -26,30 +28,28 @@ void main() {
}''';

group('JsonSchemaForm', () {
testWidgets('should render form fields based on JSON schema',
(tester) async {
await tester.pumpWidget(
Widget jsonSchemaFormTestWidget({
void Function(Map<String, String>)? onSubmit,
}) =>
WidgetHelpers.testableWidget(
child: JsonSchemaForm(
schema: jsonSchemaString,
onSubmit: (_) {},
state: PaymentDetailsState(
selectedPaymentMethod:
PaymentMethod(kind: '', schema: jsonSchemaString),
),
onSubmit: onSubmit ?? (_) {},
),
),
);
);
testWidgets('should render form fields based on JSON schema',
(tester) async {
await tester.pumpWidget(jsonSchemaFormTestWidget());

expect(find.text('Name'), findsOneWidget);
expect(find.text('Email'), findsOneWidget);
});

testWidgets('should validate form fields correctly', (tester) async {
await tester.pumpWidget(
WidgetHelpers.testableWidget(
child: JsonSchemaForm(
schema: jsonSchemaString,
onSubmit: (_) {},
),
),
);
await tester.pumpWidget(jsonSchemaFormTestWidget());

await tester.tap(find.text('Next'));
await tester.pump();
Expand All @@ -67,14 +67,10 @@ void main() {
testWidgets('should call onSubmit with correct data when form is valid',
(tester) async {
Map<String, String>? submittedData;

await tester.pumpWidget(
WidgetHelpers.testableWidget(
child: JsonSchemaForm(
schema: jsonSchemaString,
onSubmit: (formData) {
submittedData = formData;
},
),
jsonSchemaFormTestWidget(
onSubmit: (formData) => submittedData = formData,
),
);

Expand Down

0 comments on commit 9aed8e8

Please sign in to comment.