Тестирование-8
This commit is contained in:
parent
2805eff3e8
commit
b750d85a5a
@ -7,7 +7,7 @@ import '../../../matule_uikit.dart';
|
||||
class BaseCardWidget extends StatelessWidget {
|
||||
final CustomTheme theme;
|
||||
final double width;
|
||||
final double height;
|
||||
final double? height;
|
||||
final Widget? child;
|
||||
|
||||
const BaseCardWidget({
|
||||
@ -68,12 +68,14 @@ class PrimaryCardWidget extends BaseCardWidget {
|
||||
required this.onRemove,
|
||||
}) : super(
|
||||
width: 335.w,
|
||||
height: 136.h,
|
||||
height: null,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(16.r),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 16.h,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
|
@ -1,12 +1,170 @@
|
||||
// import 'package:flutter_test/flutter_test.dart';
|
||||
//
|
||||
// import 'package:matule_uikit/matule_uikit.dart';
|
||||
//
|
||||
// void main() {
|
||||
// test('adds one to input values', () {
|
||||
// final calculator = Calculator();
|
||||
// expect(calculator.addOne(2), 3);
|
||||
// expect(calculator.addOne(-7), -6);
|
||||
// expect(calculator.addOne(0), 1);
|
||||
// });
|
||||
// }
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:matule_uikit/matule_uikit.dart';
|
||||
|
||||
void main() {
|
||||
group("Widgets", () {
|
||||
testWidgets("InputWidget", (tester) async {
|
||||
late final CustomTheme theme;
|
||||
await tester.pumpWidget(
|
||||
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