mirror of
https://github.com/foss42/apidash.git
synced 2025-05-31 06:08:09 +08:00
wip: widget tests
This commit is contained in:
44
test/widgets/button_repo_test.dart
Normal file
44
test/widgets/button_repo_test.dart
Normal file
@ -0,0 +1,44 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:apidash/widgets/button_repo.dart';
|
||||
|
||||
import '../test_consts.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Testing for Repo button', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
title: 'Repo button',
|
||||
theme: kThemeDataLight,
|
||||
home: const Scaffold(
|
||||
body: RepoButton(
|
||||
icon: Icons.code,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byIcon(Icons.code), findsOneWidget);
|
||||
expect(find.text("GitHub"), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Testing for Repo button icon = null', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
title: 'Repo button',
|
||||
theme: kThemeDataLight,
|
||||
home: const Scaffold(
|
||||
body: RepoButton(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byIcon(Icons.code), findsNothing);
|
||||
expect(find.text("GitHub"), findsOneWidget);
|
||||
|
||||
final button1 = find.byType(FilledButton);
|
||||
expect(button1, findsOneWidget);
|
||||
|
||||
expect(tester.widget<FilledButton>(button1).enabled, isTrue);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user