forked from eatvio/eatvio_app
146 lines
4.3 KiB
Dart
146 lines
4.3 KiB
Dart
import 'package:eatvio_app/features/diary/models/consultant_review_model.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('ConsultantReviewModel', () {
|
|
test('creates ConsultantReviewModel with all parameters', () {
|
|
final consultantComments = ConsultantComments(
|
|
dayComment: 'Good progress',
|
|
mealsComments: [
|
|
MealComment(comment: 'Breakfast looks good', typeNo: 1),
|
|
],
|
|
portionsComments: [
|
|
PortionComment(portionId: 1, comment: 'Increase portion'),
|
|
],
|
|
);
|
|
|
|
final model = ConsultantReviewModel(
|
|
planName: 'Weight Loss Plan',
|
|
planDuration: 30,
|
|
currentPlanDay: 5,
|
|
consultantComments: consultantComments,
|
|
);
|
|
|
|
expect(model.planName, 'Weight Loss Plan');
|
|
expect(model.planDuration, 30);
|
|
expect(model.currentPlanDay, 5);
|
|
expect(model.consultantComments.dayComment, 'Good progress');
|
|
expect(model.consultantComments.mealsComments.length, 1);
|
|
expect(model.consultantComments.portionsComments.length, 1);
|
|
});
|
|
|
|
test('creates ConsultantReviewModel with null dayComment', () {
|
|
final consultantComments = ConsultantComments(
|
|
dayComment: null,
|
|
mealsComments: [],
|
|
portionsComments: [],
|
|
);
|
|
|
|
final model = ConsultantReviewModel(
|
|
planName: 'Muscle Gain Plan',
|
|
planDuration: 60,
|
|
currentPlanDay: 10,
|
|
consultantComments: consultantComments,
|
|
);
|
|
|
|
expect(model.consultantComments.dayComment, null);
|
|
expect(model.consultantComments.mealsComments, isEmpty);
|
|
expect(model.consultantComments.portionsComments, isEmpty);
|
|
});
|
|
|
|
test('creates ConsultantReviewModel from JSON', () {
|
|
final json = {
|
|
'planName': 'Weight Loss Plan',
|
|
'planDuration': 30,
|
|
'currentPlanDay': 5,
|
|
'consultantComments': {
|
|
'dayComment': 'Good progress',
|
|
'mealsComments': [
|
|
{'comment': 'Breakfast looks good', 'typeNo': 1},
|
|
],
|
|
'portionsComments': [
|
|
{'id': 1, 'comment': 'Increase portion'},
|
|
],
|
|
},
|
|
};
|
|
|
|
final model = ConsultantReviewModel.fromJson(json);
|
|
|
|
expect(model.planName, 'Weight Loss Plan');
|
|
expect(model.planDuration, 30);
|
|
expect(model.currentPlanDay, 5);
|
|
expect(model.consultantComments.dayComment, 'Good progress');
|
|
expect(model.consultantComments.mealsComments.length, 1);
|
|
expect(model.consultantComments.portionsComments.length, 1);
|
|
});
|
|
});
|
|
|
|
group('ConsultantComments', () {
|
|
test('creates ConsultantComments with all parameters', () {
|
|
final comments = ConsultantComments(
|
|
dayComment: 'Great day!',
|
|
mealsComments: [
|
|
MealComment(comment: 'Breakfast is perfect', typeNo: 1),
|
|
MealComment(comment: 'Lunch needs improvement', typeNo: 2),
|
|
],
|
|
portionsComments: [
|
|
PortionComment(portionId: 1, comment: 'Increase'),
|
|
PortionComment(portionId: 2, comment: 'Decrease'),
|
|
],
|
|
);
|
|
|
|
expect(comments.dayComment, 'Great day!');
|
|
expect(comments.mealsComments.length, 2);
|
|
expect(comments.portionsComments.length, 2);
|
|
});
|
|
});
|
|
|
|
group('MealComment', () {
|
|
test('creates MealComment with all parameters', () {
|
|
final comment = MealComment(
|
|
comment: 'Good meal',
|
|
typeNo: 1,
|
|
);
|
|
|
|
expect(comment.comment, 'Good meal');
|
|
expect(comment.typeNo, 1);
|
|
});
|
|
|
|
test('creates MealComment from JSON', () {
|
|
final json = {
|
|
'comment': 'Good meal',
|
|
'typeNo': 1,
|
|
};
|
|
|
|
final comment = MealComment.fromJson(json);
|
|
|
|
expect(comment.comment, 'Good meal');
|
|
expect(comment.typeNo, 1);
|
|
});
|
|
});
|
|
|
|
group('PortionComment', () {
|
|
test('creates PortionComment with all parameters', () {
|
|
final comment = PortionComment(
|
|
portionId: 1,
|
|
comment: 'Increase portion',
|
|
);
|
|
|
|
expect(comment.portionId, 1);
|
|
expect(comment.comment, 'Increase portion');
|
|
});
|
|
|
|
test('creates PortionComment from JSON', () {
|
|
final json = {
|
|
'id': 1,
|
|
'comment': 'Increase portion',
|
|
};
|
|
|
|
final comment = PortionComment.fromJson(json);
|
|
|
|
expect(comment.portionId, 1);
|
|
expect(comment.comment, 'Increase portion');
|
|
});
|
|
});
|
|
}
|