mirror of
https://github.com/hmalik144/easy_cc_flutter.git
synced 2025-12-10 03:05:34 +00:00
Merge pull request #11 from hmalik144/widget_testing
widget tests added
This commit is contained in:
25
test/widget_test/converter_edit_text_test.dart
Normal file
25
test/widget_test/converter_edit_text_test.dart
Normal 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);
|
||||
});
|
||||
}
|
||||
18
test/widget_test/drop_down_box_test.dart
Normal file
18
test/widget_test/drop_down_box_test.dart
Normal 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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user