forked from eatvio/eatvio_app
feat(dependencies): add rxdart package and improve string extension methods for better handling of empty strings and gender parsing
This commit is contained in:
61
test/features/diary/models/nutrition_model_test.dart
Normal file
61
test/features/diary/models/nutrition_model_test.dart
Normal file
@@ -0,0 +1,61 @@
|
||||
import 'package:eatvio_app/features/diary/models/nutrition_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('NutritionModel', () {
|
||||
test('создает NutritionModel с правильными значениями', () {
|
||||
const model = NutritionModel(
|
||||
energy: 2000.0,
|
||||
proteins: 100.0,
|
||||
fats: 50.0,
|
||||
carbohydrates: 250.0,
|
||||
);
|
||||
|
||||
expect(model.energy, 2000.0);
|
||||
expect(model.proteins, 100.0);
|
||||
expect(model.fats, 50.0);
|
||||
expect(model.carbohydrates, 250.0);
|
||||
});
|
||||
|
||||
test('fromJson создает NutritionModel из JSON', () {
|
||||
final json = {
|
||||
'energy': 2000.0,
|
||||
'proteins': 100.0,
|
||||
'fats': 50.0,
|
||||
'carbohydrates': 250.0,
|
||||
};
|
||||
|
||||
final model = NutritionModel.fromJson(json);
|
||||
|
||||
expect(model.energy, 2000.0);
|
||||
expect(model.proteins, 100.0);
|
||||
});
|
||||
});
|
||||
|
||||
group('NutritionDataModel', () {
|
||||
test('создает NutritionDataModel с правильными значениями', () {
|
||||
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,
|
||||
);
|
||||
|
||||
expect(model.dailyNutritionIntake.energy, 2000.0);
|
||||
expect(model.dailyNutritionRecommendation.energy, 2500.0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user