forked from eatvio/eatvio_app
52 lines
1.5 KiB
Dart
52 lines
1.5 KiB
Dart
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>());
|
|
});
|
|
});
|
|
}
|
|
|