mirror of
https://github.com/foss42/apidash.git
synced 2025-06-07 03:48:11 +08:00
Create texts_test.dart
This commit is contained in:
47
test/widgets/texts_test.dart
Normal file
47
test/widgets/texts_test.dart
Normal file
@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:apidash/utils/utils.dart' show getDarkModeColor;
|
||||
import 'package:apidash/widgets/texts.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Testing when method is GET', (tester) async {
|
||||
var methodGet = HTTPVerb.get;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
title: 'Texts',
|
||||
theme: ThemeData(brightness: Brightness.light),
|
||||
home: Scaffold(
|
||||
body: MethodBox(method: methodGet),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(SizedBox), findsOneWidget);
|
||||
expect(find.text('GET'), findsOneWidget);
|
||||
expect(find.text('DEL'), findsNothing);
|
||||
final getTextWithColor = find.byWidgetPredicate((widget) =>
|
||||
widget is Text && widget.style!.color == kColorHttpMethodGet);
|
||||
expect(getTextWithColor, findsOneWidget);
|
||||
});
|
||||
testWidgets('Testing when method is DELETE', (tester) async {
|
||||
var methodDel = HTTPVerb.delete;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
title: 'Texts',
|
||||
theme: ThemeData(brightness: Brightness.dark),
|
||||
home: Scaffold(
|
||||
body: MethodBox(method: methodDel),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.byType(SizedBox), findsOneWidget);
|
||||
expect(find.text('DEL'), findsOneWidget);
|
||||
expect(find.text('GET'), findsNothing);
|
||||
Color colDelDarkMode = getDarkModeColor(kColorHttpMethodDelete);
|
||||
final delTextWithColor = find.byWidgetPredicate(
|
||||
(widget) => widget is Text && widget.style!.color == colDelDarkMode);
|
||||
expect(delTextWithColor, findsOneWidget);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user