@@ -3,35 +3,143 @@ import 'package:flutter_test/flutter_test.dart';
void main ( ) {
group ( ' ConsultantReviewModel ' , ( ) {
test ( ' создает ConsultantReviewModel с правильными значениями' , ( ) {
final comments = ConsultantComments (
dayComment: ' Day comment ' ,
test ( ' creates ConsultantReviewModel with all parameters ' , ( ) {
final consultantCo mments = ConsultantComments (
dayComment: ' Good progress ' ,
mealsComments: [
MealComment (
comment: ' Meal comment ' ,
typeNo: 1 ,
) ,
MealComment ( comment: ' Breakfast looks good ' , typeNo: 1 ) ,
] ,
portionsComments: [
PortionComment (
portionId: 1 ,
comment: ' Portion comment ' ,
) ,
PortionComment ( portionId: 1 , comment: ' Increase portion ' ) ,
] ,
) ;
final model = ConsultantReviewModel (
planName: ' Test Plan' ,
planName: ' Weight Loss Plan' ,
planDuration: 30 ,
currentPlanDay: 5 ,
consultantComments: comments ,
consultantComments: consultantCo mments ,
) ;
expect ( model . planName , ' Test Plan' ) ;
expect ( model . planName , ' Weight Loss Plan' ) ;
expect ( model . planDuration , 30 ) ;
expect ( model . currentPlanDay , 5 ) ;
expect ( model . consultantComments . dayComment , ' Day comment ' ) ;
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 ' ) ;
} ) ;
} ) ;
}