forked from eatvio/eatvio_app
feat(tests): updated tests coverage to 66.5%
This commit is contained in:
51
test/features/profile/models/circumference_model_test.dart
Normal file
51
test/features/profile/models/circumference_model_test.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:eatvio_app/features/profile/models/circumference_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('CircumferenceModel', () {
|
||||
test('fromJson parses all fields correctly', () {
|
||||
final json = {
|
||||
'id': 1,
|
||||
'user_id': 123,
|
||||
'chest_circumference': 100,
|
||||
'waist_circumference': 80,
|
||||
'hip_circumference': 95,
|
||||
'created_at': '2024-01-15T10:00:00Z',
|
||||
'updated_at': '2024-01-16T10:00:00Z',
|
||||
};
|
||||
|
||||
final model = CircumferenceModel.fromJson(json);
|
||||
|
||||
expect(model.id, 1);
|
||||
expect(model.userId, 123);
|
||||
expect(model.chestCircumference, 100);
|
||||
expect(model.waistCircumference, 80);
|
||||
expect(model.hipCircumference, 95);
|
||||
expect(model.createdAt, isA<DateTime>());
|
||||
expect(model.updatedAt, isA<DateTime>());
|
||||
});
|
||||
|
||||
test('toJson serializes all fields correctly', () {
|
||||
final model = CircumferenceModel(
|
||||
id: 1,
|
||||
userId: 123,
|
||||
chestCircumference: 100,
|
||||
waistCircumference: 80,
|
||||
hipCircumference: 95,
|
||||
createdAt: DateTime(2024, 1, 15, 10, 0, 0),
|
||||
updatedAt: DateTime(2024, 1, 16, 10, 0, 0),
|
||||
);
|
||||
|
||||
final json = model.toJson();
|
||||
|
||||
expect(json['id'], 1);
|
||||
expect(json['user_id'], 123);
|
||||
expect(json['chest_circumference'], 100);
|
||||
expect(json['waist_circumference'], 80);
|
||||
expect(json['hip_circumference'], 95);
|
||||
expect(json['created_at'], isA<String>());
|
||||
expect(json['updated_at'], isA<String>());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user