forked from eatvio/eatvio_app
test(tests): add comprehensive unit tests for various models and repositories, enhancing test coverage and ensuring correct functionality
This commit is contained in:
@@ -32,6 +32,30 @@ void main() {
|
||||
expect(model.mealsComments.length, 1);
|
||||
expect(model.portions.length, 1);
|
||||
});
|
||||
|
||||
test('fromJson создает ConsultantCommentModel из JSON', () {
|
||||
final json = {
|
||||
'comment': 'General comment',
|
||||
'meals': {
|
||||
'breakfast': {
|
||||
'comment': 'Breakfast comment',
|
||||
'type_no': 1,
|
||||
},
|
||||
},
|
||||
'portions': [
|
||||
{
|
||||
'comment': 'Portion comment',
|
||||
'id': 1,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
final model = ConsultantCommentModel.fromJson(json);
|
||||
|
||||
expect(model.comment, 'General comment');
|
||||
expect(model.mealsComments.length, 1);
|
||||
expect(model.portions.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
group('MealCommentModel', () {
|
||||
@@ -44,6 +68,18 @@ void main() {
|
||||
expect(model.comment, 'Test comment');
|
||||
expect(model.typeNumber, 1);
|
||||
});
|
||||
|
||||
test('fromJson создает MealCommentModel из JSON', () {
|
||||
final json = {
|
||||
'comment': 'Test comment',
|
||||
'type_no': 1,
|
||||
};
|
||||
|
||||
final model = MealCommentModel.fromJson(json);
|
||||
|
||||
expect(model.comment, 'Test comment');
|
||||
expect(model.typeNumber, 1);
|
||||
});
|
||||
});
|
||||
|
||||
group('PortionCommentModel', () {
|
||||
@@ -56,6 +92,18 @@ void main() {
|
||||
expect(model.comment, 'Portion comment');
|
||||
expect(model.id, 1);
|
||||
});
|
||||
|
||||
test('fromJson создает PortionCommentModel из JSON', () {
|
||||
final json = {
|
||||
'comment': 'Portion comment',
|
||||
'id': 1,
|
||||
};
|
||||
|
||||
final model = PortionCommentModel.fromJson(json);
|
||||
|
||||
expect(model.comment, 'Portion comment');
|
||||
expect(model.id, 1);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,33 @@ void main() {
|
||||
|
||||
expect(model.comment, isNull);
|
||||
});
|
||||
|
||||
test('fromJson создает FinishDiaryDayModel из JSON', () {
|
||||
final json = {
|
||||
'wakeUp': '08:00',
|
||||
'retire': '22:00',
|
||||
'comment': 'Test comment',
|
||||
};
|
||||
|
||||
final model = FinishDiaryDayModel.fromJson(json);
|
||||
|
||||
expect(model.wakeUp, '08:00');
|
||||
expect(model.retire, '22:00');
|
||||
expect(model.comment, 'Test comment');
|
||||
});
|
||||
|
||||
test('fromJson создает FinishDiaryDayModel из JSON без комментария', () {
|
||||
final json = {
|
||||
'wakeUp': '08:00',
|
||||
'retire': '22:00',
|
||||
};
|
||||
|
||||
final model = FinishDiaryDayModel.fromJson(json);
|
||||
|
||||
expect(model.wakeUp, '08:00');
|
||||
expect(model.retire, '22:00');
|
||||
expect(model.comment, isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user