Added tests for DropdownButtonContentType

This commit is contained in:
Ashita Prasad
2023-04-22 03:50:58 +05:30
parent cc6fedaebe
commit ef2035252f

View File

@ -45,4 +45,46 @@ void main() {
expect(changedValue, HTTPVerb.put);
});
testWidgets('Testing Dropdown for Content Type', (tester) async {
dynamic changedValue;
await tester.pumpWidget(
MaterialApp(
title: 'Dropdown Content Type testing',
theme: kThemeDataLight,
home: Scaffold(
body: Center(
child: Column(
children: [
DropdownButtonContentType(
contentType: ContentType.json,
onChanged: (value) {
changedValue = value!;
},
),
],
),
),
),
),
);
expect(find.byIcon(Icons.unfold_more_rounded), findsOneWidget);
expect(find.byType(DropdownButton<ContentType>), findsOneWidget);
expect(
(tester.widget(find.byType(DropdownButton<ContentType>))
as DropdownButton)
.value,
equals(ContentType.json));
await tester.tap(find.text('json'));
await tester.pump();
await tester.pump(const Duration(seconds: 1));
await tester.tap(find.text('text').last);
await tester.pump();
await tester.pump(const Duration(seconds: 1));
expect(changedValue, ContentType.text);
});
}