feat(tests): updated tests coverage to 66.5%

This commit is contained in:
misha
2026-01-14 18:47:11 +03:00
parent 497ff19cfa
commit 13ccf56df0
102 changed files with 10146 additions and 379 deletions

View File

@@ -30,6 +30,22 @@ void main() {
expect(model.energy, 2000.0);
expect(model.proteins, 100.0);
});
test('toJson serializes NutritionModel correctly', () {
const model = NutritionModel(
energy: 2000.0,
proteins: 100.0,
fats: 50.0,
carbohydrates: 250.0,
);
final json = model.toJson();
expect(json['energy'], 2000.0);
expect(json['proteins'], 100.0);
expect(json['fats'], 50.0);
expect(json['carbohydrates'], 250.0);
});
});
group('NutritionDataModel', () {
@@ -56,6 +72,54 @@ void main() {
expect(model.dailyNutritionIntake.energy, 2000.0);
expect(model.dailyNutritionRecommendation.energy, 2500.0);
});
test('fromJson создает NutritionDataModel из JSON', () {
final json = {
'dailyNutritionIntake': {
'energy': 2000.0,
'proteins': 100.0,
'fats': 50.0,
'carbohydrates': 250.0,
},
'dailyNutritionRecommendation': {
'energy': 2500.0,
'proteins': 120.0,
'fats': 60.0,
'carbohydrates': 300.0,
},
};
final model = NutritionDataModel.fromJson(json);
expect(model.dailyNutritionIntake.energy, 2000.0);
expect(model.dailyNutritionRecommendation.energy, 2500.0);
});
test('toJson serializes NutritionDataModel correctly', () {
const intake = NutritionModel(
energy: 2000.0,
proteins: 100.0,
fats: 50.0,
carbohydrates: 250.0,
);
const recommendation = NutritionModel(
energy: 2500.0,
proteins: 120.0,
fats: 60.0,
carbohydrates: 300.0,
);
const model = NutritionDataModel(
dailyNutritionIntake: intake,
dailyNutritionRecommendation: recommendation,
);
final json = model.toJson();
expect(json.containsKey('dailyNutritionIntake'), isTrue);
expect(json.containsKey('dailyNutritionRecommendation'), isTrue);
});
});
}