mirror of
https://github.com/foss42/apidash.git
synced 2025-12-11 15:49:48 +08:00
Refactor DashBot
This commit is contained in:
30
test/dashbot/widgets/home_screen_task_button_test.dart
Normal file
30
test/dashbot/widgets/home_screen_task_button_test.dart
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user