Тестирование-8
This commit is contained in:
parent
2805eff3e8
commit
b750d85a5a
@ -7,7 +7,7 @@ import '../../../matule_uikit.dart';
|
|||||||
class BaseCardWidget extends StatelessWidget {
|
class BaseCardWidget extends StatelessWidget {
|
||||||
final CustomTheme theme;
|
final CustomTheme theme;
|
||||||
final double width;
|
final double width;
|
||||||
final double height;
|
final double? height;
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
|
|
||||||
const BaseCardWidget({
|
const BaseCardWidget({
|
||||||
@ -68,12 +68,14 @@ class PrimaryCardWidget extends BaseCardWidget {
|
|||||||
required this.onRemove,
|
required this.onRemove,
|
||||||
}) : super(
|
}) : super(
|
||||||
width: 335.w,
|
width: 335.w,
|
||||||
height: 136.h,
|
height: null,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.all(16.r),
|
padding: EdgeInsets.all(16.r),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
spacing: 16.h,
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
|
@ -1,12 +1,170 @@
|
|||||||
// import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter/material.dart';
|
||||||
//
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
// import 'package:matule_uikit/matule_uikit.dart';
|
import 'package:matule_uikit/matule_uikit.dart';
|
||||||
//
|
|
||||||
// void main() {
|
void main() {
|
||||||
// test('adds one to input values', () {
|
group("Widgets", () {
|
||||||
// final calculator = Calculator();
|
testWidgets("InputWidget", (tester) async {
|
||||||
// expect(calculator.addOne(2), 3);
|
late final CustomTheme theme;
|
||||||
// expect(calculator.addOne(-7), -6);
|
await tester.pumpWidget(
|
||||||
// expect(calculator.addOne(0), 1);
|
UtilsMaterialWrapper(
|
||||||
// });
|
widget: Builder(
|
||||||
// }
|
builder: (context) {
|
||||||
|
theme = CustomTheme.of(context);
|
||||||
|
return InputWidget(
|
||||||
|
label: "",
|
||||||
|
hint: "",
|
||||||
|
error: "error",
|
||||||
|
controller: TextEditingController(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
TextField textField = tester.firstWidget(find.byType(TextField));
|
||||||
|
expect(
|
||||||
|
((textField.decoration) as InputDecoration).fillColor,
|
||||||
|
theme.palette.errorOld.withValues(alpha: 0.1),
|
||||||
|
reason: "BackgroundColor",
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
(((textField.decoration) as InputDecoration).enabledBorder
|
||||||
|
as OutlineInputBorder)
|
||||||
|
.borderSide
|
||||||
|
.color,
|
||||||
|
theme.palette.errorOld,
|
||||||
|
reason: "StrokeColor",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
testWidgets("ChipsButton", (tester) async {
|
||||||
|
late final CustomTheme theme;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
UtilsMaterialWrapper(
|
||||||
|
widget: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
theme = CustomTheme.of(context);
|
||||||
|
return ChipsButtonWidget(
|
||||||
|
theme: theme,
|
||||||
|
active: true,
|
||||||
|
onTap: () {},
|
||||||
|
text: "",
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
FilledButton filledButton = tester.firstWidget(find.byType(FilledButton));
|
||||||
|
expect(
|
||||||
|
(filledButton.style as ButtonStyle).backgroundColor?.resolve({}),
|
||||||
|
theme.palette.accentOld,
|
||||||
|
reason: "Active BackgroundColor",
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
((filledButton.child as Text).style as TextStyle).color,
|
||||||
|
theme.palette.whiteOld,
|
||||||
|
reason: "Active TextColor",
|
||||||
|
);
|
||||||
|
await tester.restoreFrom(TestRestorationData.empty);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
UtilsMaterialWrapper(
|
||||||
|
widget: ChipsButtonWidget(
|
||||||
|
theme: theme,
|
||||||
|
active: false,
|
||||||
|
onTap: () {},
|
||||||
|
text: "",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
filledButton = tester.firstWidget(find.byType(FilledButton));
|
||||||
|
expect(
|
||||||
|
(filledButton.style as ButtonStyle).backgroundColor?.resolve({}),
|
||||||
|
theme.palette.inputBackgroundOld,
|
||||||
|
reason: "Disabled BackgroundColor",
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
((filledButton.child as Text).style as TextStyle).color,
|
||||||
|
theme.palette.descriptionOld,
|
||||||
|
reason: "Disabled TextColor",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
testWidgets("PrimaryCard", (tester) async {
|
||||||
|
late final CustomTheme theme;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
UtilsMaterialWrapper(
|
||||||
|
widget: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
theme = CustomTheme.of(context);
|
||||||
|
return PrimaryCardWidget(
|
||||||
|
theme: theme,
|
||||||
|
label: "label",
|
||||||
|
category: "category",
|
||||||
|
price: 0,
|
||||||
|
added: false,
|
||||||
|
onAdd: () {},
|
||||||
|
onRemove: () {},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
SmallButtonWidget smallButtonWidget = tester.firstWidget(
|
||||||
|
find.byType(SmallButtonWidget),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
smallButtonWidget.backgroundColor,
|
||||||
|
theme.palette.accent,
|
||||||
|
reason: "Non-Added PrimaryCard's SmallButton BackgroundColor",
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
smallButtonWidget.text,
|
||||||
|
"Добавить",
|
||||||
|
reason: "Non-Added PrimaryCard's SmallButton Text",
|
||||||
|
);
|
||||||
|
// expect(
|
||||||
|
// (filledButton.style as ButtonStyle).backgroundColor?.resolve({}),
|
||||||
|
// theme.palette.accentOld,
|
||||||
|
// reason: "Active BackgroundColor",
|
||||||
|
// );
|
||||||
|
// expect(
|
||||||
|
// ((filledButton.child as Text).style as TextStyle).color,
|
||||||
|
// theme.palette.whiteOld,
|
||||||
|
// reason: "Active TextColor",
|
||||||
|
// );
|
||||||
|
await tester.restoreFrom(TestRestorationData.empty);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
UtilsMaterialWrapper(
|
||||||
|
widget: PrimaryCardWidget(
|
||||||
|
theme: theme,
|
||||||
|
label: "label",
|
||||||
|
category: "category",
|
||||||
|
price: 0,
|
||||||
|
added: true,
|
||||||
|
onAdd: () {},
|
||||||
|
onRemove: () {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
smallButtonWidget = tester.firstWidget(find.byType(SmallButtonWidget));
|
||||||
|
expect(
|
||||||
|
smallButtonWidget.backgroundColor,
|
||||||
|
Colors.transparent,
|
||||||
|
reason: "Added PrimaryCard's SmallButton BackgroundColor",
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
smallButtonWidget.text,
|
||||||
|
"Убрать",
|
||||||
|
reason: "Added PrimaryCard's SmallButton Text",
|
||||||
|
);
|
||||||
|
// expect(
|
||||||
|
// (filledButton.style as ButtonStyle).backgroundColor?.resolve({}),
|
||||||
|
// theme.palette.inputBackgroundOld,
|
||||||
|
// reason: "Disabled BackgroundColor",
|
||||||
|
// );
|
||||||
|
// expect(
|
||||||
|
// ((filledButton.child as Text).style as TextStyle).color,
|
||||||
|
// theme.palette.descriptionOld,
|
||||||
|
// reason: "Disabled TextColor",
|
||||||
|
// );
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user