Update popup_menu_uri_test.dart

This commit is contained in:
Ashita Prasad
2024-12-15 07:37:29 +05:30
parent 2bb54ec4d6
commit f479d33522

View File

@ -1,36 +1,35 @@
import 'package:apidash_core/apidash_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:apidash/widgets/popup_menu_uri.dart';
void main() {
testWidgets('URIPopupMenu displays initial value',
testWidgets('DefaultUriSchemePopupMenu displays initial value',
(WidgetTester tester) async {
const uriScheme = 'https';
const uriScheme = SupportedUriSchemes.https;
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: URIPopupMenu(
body: DefaultUriSchemePopupMenu(
value: uriScheme,
items: [uriScheme],
),
),
),
);
expect(find.text(uriScheme), findsOneWidget);
expect(find.text(uriScheme.name), findsOneWidget);
});
testWidgets('URIPopupMenu displays popup menu items',
testWidgets('DefaultUriSchemePopupMenu displays popup menu items',
(WidgetTester tester) async {
const uriScheme1 = 'https';
const uriScheme2 = 'http';
const uriScheme1 = SupportedUriSchemes.https;
const uriScheme2 = SupportedUriSchemes.http;
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: URIPopupMenu(
items: [uriScheme1, uriScheme2],
body: DefaultUriSchemePopupMenu(
value: uriScheme1,
),
),
@ -40,22 +39,22 @@ void main() {
await tester.tap(find.byIcon(Icons.unfold_more));
await tester.pumpAndSettle();
expect(find.text(uriScheme1), findsExactly(2));
expect(find.text(uriScheme2), findsOneWidget);
expect(find.text(uriScheme1.name), findsExactly(2));
expect(find.text(uriScheme2.name), findsOneWidget);
});
testWidgets('URIPopupMenu calls onChanged when an item is selected',
testWidgets(
'DefaultUriSchemePopupMenu calls onChanged when an item is selected',
(WidgetTester tester) async {
const uriScheme1 = 'https';
const uriScheme2 = 'http';
String? selectedScheme;
const uriScheme1 = SupportedUriSchemes.https;
const uriScheme2 = SupportedUriSchemes.http;
SupportedUriSchemes? selectedScheme;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: URIPopupMenu(
body: DefaultUriSchemePopupMenu(
value: uriScheme1,
items: const [uriScheme1, uriScheme2],
onChanged: (value) {
selectedScheme = value;
},
@ -67,7 +66,7 @@ void main() {
await tester.tap(find.byIcon(Icons.unfold_more));
await tester.pumpAndSettle();
await tester.tap(find.text(uriScheme2).last);
await tester.tap(find.text(uriScheme2.name).last);
await tester.pumpAndSettle();
expect(selectedScheme, uriScheme2);