ui_kit/test/ui_kit_test.dart
2025-05-26 17:25:20 +03:00

72 lines
2.2 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:ui_kit/ui_kit.dart';
void main() {
testWidgets(
"Инпут ошибки. Проверяемые параметры: фон, обводка, Наличие текста ошибки и соответствие его цвета",
(WidgetTester tester) async {
final TextEditingController controller = TextEditingController();
await tester.pumpWidget(
MaterialApp(
builder: (context, child) => Scaffold(
body: Column(
children: [
InputWidget(
controller: controller,
hintText: 'This error input',
errorText: 'Eror Input Text',
isError: 'true',
),
],
),
),
),
);
await tester.pumpAndSettle();
final input = find.byType(InputWidget);
expect(input.hasFound, true);
},
);
testWidgets(
"Кнопка chips. Кнопка при значениях status ON и OFF соответствует макету",
(WidgetTester tester) async {
bool isSelected = false;
Color bgColor = primaryColor;
await tester.pumpWidget(
MaterialApp(
builder: (context, child) => Scaffold(
body: Column(
children: [
TextButton(
onPressed: () {
isSelected = !isSelected;
bgColor = bgColor == primaryColor
? inputBgColor
: primaryColor;
},
child: Text('Click to make chip enabled'),
),
Chips(
buttonText: 'Testtest',
buttonStyle: title2Semibold,
bgColor: bgColor,
),
],
),
),
),
);
await tester.pumpAndSettle();
final currentWidget = find.widgetWithText(
TextButton,
'Click to make chip enabled',
);
await tester.tap(currentWidget);
expect(isSelected, true);
expect(bgColor, inputBgColor);
},
);
}