mirror of
https://github.com/foss42/apidash.git
synced 2025-12-02 10:49:49 +08:00
31 lines
856 B
Dart
31 lines
856 B
Dart
import 'package:apidash/dashbot/widgets/home_screen_task_button.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
testWidgets('HomeScreenTaskButton renders label and invokes callback',
|
|
(tester) async {
|
|
var tapped = false;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: HomeScreenTaskButton(
|
|
label: 'Perform action',
|
|
textAlign: TextAlign.left,
|
|
onPressed: () => tapped = true,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
expect(find.text('Perform action'), findsOneWidget);
|
|
final textWidget = tester.widget<Text>(find.text('Perform action'));
|
|
expect(textWidget.textAlign, TextAlign.left);
|
|
|
|
await tester.tap(find.byType(TextButton));
|
|
await tester.pump();
|
|
|
|
expect(tapped, isTrue);
|
|
});
|
|
}
|