Merge pull request #11 from hmalik144/widget_testing

widget tests added
This commit is contained in:
2022-10-08 17:09:34 +01:00
committed by GitHub
2 changed files with 43 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
import 'package:easy_cc_flutter/views/converter_edit_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('converter edit text controls test', (tester) async {
// Create the widget by telling the tester to build it.
const hintText = "Test hint text";
const enterText = "some random text";
TextEditingController controller = TextEditingController();
final box = ConverterEditText(hintText, controller, (input) {
expect(find.text(input!), findsOneWidget);
});
await tester.pumpWidget(MaterialApp(
home: Material(child: box),
));
final hintFinder = find.text(hintText);
expect(hintFinder, findsOneWidget);
controller.text = enterText;
final textFinder = find.text(hintText);
expect(textFinder, findsOneWidget);
});
}

View File

@@ -0,0 +1,18 @@
import 'package:easy_cc_flutter/Utils/constants.dart';
import 'package:easy_cc_flutter/views/drop_down_box.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Drop down box has hint present', (tester) async {
// Create the widget by telling the tester to build it.
const hintText = "Test hint text";
final box = DropDownBox(listOfCurrencies, hintText, (selected) {});
await tester.pumpWidget(MaterialApp(
home: box,
));
final hintFinder = find.text(hintText);
expect(hintFinder, findsOneWidget);
});
}