forked from eatvio/eatvio_app
feat(insights): first isights impemetation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
|
||||
import 'package:eatvio_app/features/profile/models/weight_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
@@ -42,6 +43,51 @@ void main() {
|
||||
expect(json['created_at'], isA<String>());
|
||||
expect(json['updated_at'], isA<String>());
|
||||
});
|
||||
|
||||
Map<String, dynamic> json({Object? weight = 72.3, Object? bmi = 22.4}) => {
|
||||
'id': 1,
|
||||
'user_id': 2,
|
||||
'weight': weight,
|
||||
'created_at': '2026-11-01T10:00:00.000000Z',
|
||||
'updated_at': '2026-11-01T10:00:00.000000Z',
|
||||
'bmi': bmi,
|
||||
};
|
||||
|
||||
test('парсит дробный weight', () {
|
||||
final model = WeightModel.fromJson(json());
|
||||
|
||||
expect(model.weight, 72.3);
|
||||
expect(model.bmi, 22.4);
|
||||
});
|
||||
|
||||
test('парсит целый weight как double', () {
|
||||
final model = WeightModel.fromJson(json(weight: 72));
|
||||
|
||||
expect(model.weight, 72.0);
|
||||
});
|
||||
|
||||
test('допускает bmi: null (рост не указан)', () {
|
||||
final model = WeightModel.fromJson(json(bmi: null));
|
||||
|
||||
expect(model.bmi, isNull);
|
||||
});
|
||||
});
|
||||
|
||||
group('CircumferenceModel', () {
|
||||
test('парсит целые и дробные значения (прореженные средние)', () {
|
||||
final model = CircumferenceModel.fromJson({
|
||||
'id': 1,
|
||||
'user_id': 2,
|
||||
'chest_circumference': 95,
|
||||
'waist_circumference': 80.5,
|
||||
'hip_circumference': 100,
|
||||
'created_at': '2026-11-01T10:00:00.000000Z',
|
||||
'updated_at': '2026-11-01T10:00:00.000000Z',
|
||||
});
|
||||
|
||||
expect(model.chestCircumference, 95.0);
|
||||
expect(model.waistCircumference, 80.5);
|
||||
expect(model.hipCircumference, 100.0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user