forked from eatvio/eatvio_app
128 lines
3.9 KiB
Dart
128 lines
3.9 KiB
Dart
import 'package:eatvio_app/features/registration/models/user_registration_model.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('UserRegistrationSheet', () {
|
|
test('creates UserRegistrationSheet with all parameters', () {
|
|
const model = UserRegistrationSheet(
|
|
firstName: 'John',
|
|
lastName: 'Doe',
|
|
email: 'john.doe@example.com',
|
|
password: 'password123',
|
|
passwordConfirmation: 'password123',
|
|
termsAccepted: 'accepted',
|
|
birthdate: '1990-01-01',
|
|
gender: 'male',
|
|
location: 'New York',
|
|
responseBody: '{}',
|
|
lang: 'en',
|
|
weight: 75,
|
|
height: 180,
|
|
phone: '+1234567890',
|
|
chestCircumference: 100,
|
|
waistCircumference: 80,
|
|
hipCircumference: 90,
|
|
bloodPressureUp: 120,
|
|
bloodPressureDown: 80,
|
|
hasHypo: 0,
|
|
hasHyper: 0,
|
|
aboutAllergy: 'None',
|
|
aboutTakingPils: 'None',
|
|
aboutSportHobbies: 'Running',
|
|
favoriteFoods: 'Pizza',
|
|
unfavoriteFoods: 'Broccoli',
|
|
additionalInfo: 'No additional info',
|
|
activityCoefficient: 1.5,
|
|
);
|
|
|
|
expect(model.firstName, 'John');
|
|
expect(model.lastName, 'Doe');
|
|
expect(model.email, 'john.doe@example.com');
|
|
expect(model.password, 'password123');
|
|
expect(model.passwordConfirmation, 'password123');
|
|
expect(model.termsAccepted, 'accepted');
|
|
expect(model.birthdate, '1990-01-01');
|
|
expect(model.gender, 'male');
|
|
expect(model.location, 'New York');
|
|
expect(model.weight, 75);
|
|
expect(model.height, 180);
|
|
expect(model.activityCoefficient, 1.5);
|
|
});
|
|
|
|
test('creates UserRegistrationSheet with default values', () {
|
|
const model = UserRegistrationSheet(
|
|
firstName: 'Jane',
|
|
lastName: 'Smith',
|
|
email: 'jane@example.com',
|
|
password: 'pass123',
|
|
passwordConfirmation: 'pass123',
|
|
birthdate: '1995-05-15',
|
|
gender: 'female',
|
|
location: 'London',
|
|
responseBody: '{}',
|
|
lang: 'en',
|
|
weight: 60,
|
|
height: 165,
|
|
phone: '+9876543210',
|
|
chestCircumference: 90,
|
|
waistCircumference: 70,
|
|
hipCircumference: 85,
|
|
bloodPressureUp: 110,
|
|
bloodPressureDown: 70,
|
|
hasHypo: 0,
|
|
hasHyper: 0,
|
|
aboutAllergy: 'Peanuts',
|
|
aboutTakingPils: 'Vitamins',
|
|
aboutSportHobbies: 'Yoga',
|
|
favoriteFoods: 'Salad',
|
|
unfavoriteFoods: 'Fast food',
|
|
additionalInfo: 'Vegetarian',
|
|
);
|
|
|
|
expect(model.termsAccepted, 'accepted'); // default
|
|
expect(model.activityCoefficient, 1.2); // default
|
|
});
|
|
|
|
test('creates UserRegistrationSheet from JSON', () {
|
|
final json = {
|
|
'first_name': 'Test',
|
|
'last_name': 'User',
|
|
'email': 'test@example.com',
|
|
'password': 'test123',
|
|
'password_confirmation': 'test123',
|
|
'terms': 'accepted',
|
|
'birthdate': '2000-01-01',
|
|
'gender': 'other',
|
|
'location': 'Paris',
|
|
'response_body': '{}',
|
|
'lang': 'fr',
|
|
'weight': 70,
|
|
'height': 170,
|
|
'phone': '+1111111111',
|
|
'chest_circumference': 95,
|
|
'waist_circumference': 75,
|
|
'hip_circumference': 88,
|
|
'blood_pressure_up': 115,
|
|
'blood_pressure_down': 75,
|
|
'has_hypo': 1,
|
|
'has_hyper': 0,
|
|
'about_alergy': 'Dairy',
|
|
'about_taking_pils': 'None',
|
|
'about_sport_hobbies': 'Swimming',
|
|
'favorite_foods': 'Fish',
|
|
'unfavorite_foods': 'Meat',
|
|
'additional_info': 'Pescatarian',
|
|
'activity_coefficient': 1.3,
|
|
};
|
|
|
|
final model = UserRegistrationSheet.fromJson(json);
|
|
|
|
expect(model.firstName, 'Test');
|
|
expect(model.lastName, 'User');
|
|
expect(model.email, 'test@example.com');
|
|
expect(model.hasHypo, 1);
|
|
expect(model.hasHyper, 0);
|
|
});
|
|
});
|
|
}
|