forked from eatvio/eatvio_app
fix: issue-372, issue-227, issue-406
This commit is contained in:
@@ -100,6 +100,22 @@ void main() {
|
||||
expect(model.dietId, 5);
|
||||
});
|
||||
|
||||
test('creates ChosenDietModel from JSON with null chosen_plan_id as public diet', () {
|
||||
final json = {
|
||||
'id': 1,
|
||||
'chosen_plan_id': null,
|
||||
'state': 'started',
|
||||
'start_date': '2023-01-01T00:00:00Z',
|
||||
'diet': {'id': 5},
|
||||
};
|
||||
|
||||
final model = ChosenDietModel.fromJson(json);
|
||||
|
||||
expect(model.chosenDietID, 1);
|
||||
expect(model.chosenPlanId, 0);
|
||||
expect(model.dietId, 5);
|
||||
});
|
||||
|
||||
test('creates ChosenDietModel with null dietId', () {
|
||||
final model = ChosenDietModel(
|
||||
chosenDietID: 1,
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import 'package:eatvio_app/features/profile/presentation/widgets/expandable_page_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('ExpandablePageView', () {
|
||||
testWidgets(
|
||||
'sizes itself to a child taller than the old fixed 781 height',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: ExpandablePageView(
|
||||
itemCount: 1,
|
||||
itemBuilder: _tallPlanCard,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text('Питание для диабетиков'), findsOneWidget);
|
||||
expect(find.text('Показать ещё'), findsOneWidget);
|
||||
|
||||
final viewSize = tester.getSize(find.byType(ExpandablePageView));
|
||||
expect(viewSize.height, greaterThan(781));
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('does not overflow a vertical Column inside a bounded parent', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SizedBox(
|
||||
height: 781,
|
||||
width: 402,
|
||||
child: SingleChildScrollView(
|
||||
child: ExpandablePageView(
|
||||
itemCount: 1,
|
||||
itemBuilder: _tallPlanCard,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text('Показать ещё'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Widget _tallPlanCard(BuildContext context, int index) {
|
||||
return const Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(width: 402, height: 426),
|
||||
SizedBox(height: 12),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Text('Питание для диабетиков'),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
SizedBox(width: 370, height: 156),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 16, top: 8),
|
||||
child: Text('Показать ещё'),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
SizedBox(height: 72),
|
||||
SizedBox(height: 16),
|
||||
SizedBox(height: 32),
|
||||
SizedBox(height: 12),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -257,6 +257,8 @@ void main() {
|
||||
|
||||
expect(find.byType(BlogPostMediaContent), findsOneWidget);
|
||||
expect(find.textContaining('Галерея и видео'), findsWidgets);
|
||||
expect(find.byType(CircleAvatar), findsNothing);
|
||||
expect(find.text(post.author.authorName), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('renders gallery-only media content', (tester) async {
|
||||
|
||||
Reference in New Issue
Block a user