mirror of
https://github.com/foss42/apidash.git
synced 2025-06-04 01:13:30 +08:00
fix: updated tests
This commit is contained in:
@ -19,11 +19,26 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byIcon(Icons.content_copy), findsOneWidget);
|
||||
expect(find.text(kLabelCopy), findsOneWidget);
|
||||
final textButton1 = find.byType(TextButton);
|
||||
expect(textButton1, findsOneWidget);
|
||||
await tester.tap(textButton1);
|
||||
final icon = find.byIcon(Icons.content_copy);
|
||||
expect(icon, findsOneWidget);
|
||||
|
||||
Finder button;
|
||||
if (tester.any(find.ancestor(
|
||||
of: icon,
|
||||
matching: find.byWidgetPredicate((widget) => widget is TextButton)))) {
|
||||
expect(find.text(kLabelCopy), findsOneWidget);
|
||||
button = find.ancestor(
|
||||
of: icon,
|
||||
matching: find.byWidgetPredicate((widget) => widget is TextButton));
|
||||
} else if (tester
|
||||
.any(find.ancestor(of: icon, matching: find.byType(IconButton)))) {
|
||||
button = find.byType(IconButton);
|
||||
} else {
|
||||
fail('No TextButton or IconButton found');
|
||||
}
|
||||
|
||||
expect(button, findsOneWidget);
|
||||
await tester.tap(button);
|
||||
|
||||
//TODO: The below test works for `flutter run` but not for `flutter test`
|
||||
//var data = await Clipboard.getData('text/plain');
|
||||
@ -91,13 +106,27 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byIcon(Icons.download), findsOneWidget);
|
||||
expect(find.text("Download"), findsOneWidget);
|
||||
final icon = find.byIcon(Icons.download);
|
||||
expect(icon, findsOneWidget);
|
||||
|
||||
final button1 = find.byType(TextButton);
|
||||
expect(button1, findsOneWidget);
|
||||
|
||||
expect(tester.widget<TextButton>(button1).enabled, isFalse);
|
||||
Finder button;
|
||||
if (tester.any(find.ancestor(
|
||||
of: icon,
|
||||
matching: find.byWidgetPredicate((widget) => widget is TextButton)))) {
|
||||
expect(find.text(kLabelDownload), findsOneWidget);
|
||||
button = find.ancestor(
|
||||
of: icon,
|
||||
matching: find.byWidgetPredicate((widget) => widget is TextButton));
|
||||
expect(button, findsOneWidget);
|
||||
expect(tester.widget<TextButton>(button).enabled, isFalse);
|
||||
} else if (tester
|
||||
.any(find.ancestor(of: icon, matching: find.byType(IconButton)))) {
|
||||
button = find.byType(IconButton);
|
||||
expect(button, findsOneWidget);
|
||||
expect(tester.widget<IconButton>(button).onPressed == null, isFalse);
|
||||
} else {
|
||||
fail('No TextButton or IconButton found');
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Testing for Save in Downloads button 2', (tester) async {
|
||||
@ -113,13 +142,27 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byIcon(Icons.download), findsOneWidget);
|
||||
expect(find.text("Download"), findsOneWidget);
|
||||
final icon = find.byIcon(Icons.download);
|
||||
expect(icon, findsOneWidget);
|
||||
|
||||
final button1 = find.byType(TextButton);
|
||||
expect(button1, findsOneWidget);
|
||||
|
||||
expect(tester.widget<TextButton>(button1).enabled, isTrue);
|
||||
Finder button;
|
||||
if (tester.any(find.ancestor(
|
||||
of: icon,
|
||||
matching: find.byWidgetPredicate((widget) => widget is TextButton)))) {
|
||||
expect(find.text(kLabelDownload), findsOneWidget);
|
||||
button = find.ancestor(
|
||||
of: icon,
|
||||
matching: find.byWidgetPredicate((widget) => widget is TextButton));
|
||||
expect(button, findsOneWidget);
|
||||
expect(tester.widget<TextButton>(button).enabled, isTrue);
|
||||
} else if (tester
|
||||
.any(find.ancestor(of: icon, matching: find.byType(IconButton)))) {
|
||||
button = find.byType(IconButton);
|
||||
expect(button, findsOneWidget);
|
||||
expect(tester.widget<IconButton>(button).onPressed == null, isTrue);
|
||||
} else {
|
||||
fail('No TextButton or IconButton found');
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('Testing for Repo button', (tester) async {
|
||||
|
@ -122,12 +122,26 @@ void main() {
|
||||
|
||||
expect(find.text('xyz (2 items)'), findsOneWidget);
|
||||
|
||||
expect(find.byIcon(Icons.content_copy), findsOneWidget);
|
||||
expect(find.text(kLabelCopy), findsOneWidget);
|
||||
final icon = find.byIcon(Icons.content_copy);
|
||||
expect(icon, findsOneWidget);
|
||||
|
||||
final textButton1 = find.byType(TextButton);
|
||||
expect(textButton1, findsOneWidget);
|
||||
await tester.tap(textButton1);
|
||||
Finder button;
|
||||
if (tester.any(find.ancestor(
|
||||
of: icon,
|
||||
matching: find.byWidgetPredicate((widget) => widget is TextButton)))) {
|
||||
expect(find.text(kLabelCopy), findsOneWidget);
|
||||
button = find.ancestor(
|
||||
of: icon,
|
||||
matching: find.byWidgetPredicate((widget) => widget is TextButton));
|
||||
} else if (tester
|
||||
.any(find.ancestor(of: icon, matching: find.byType(IconButton)))) {
|
||||
button = find.byType(IconButton);
|
||||
} else {
|
||||
fail('No TextButton or IconButton found');
|
||||
}
|
||||
|
||||
expect(button, findsOneWidget);
|
||||
await tester.tap(button);
|
||||
});
|
||||
|
||||
testWidgets('Testing Response Headers', (tester) async {
|
||||
|
Reference in New Issue
Block a user