forked from eatvio/eatvio_app
85 lines
2.7 KiB
Dart
85 lines
2.7 KiB
Dart
import 'package:eatvio_app/features/registration_v2/cubit/registration_state.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('RegistrationStateV2', () {
|
|
test('creates instance with default values', () {
|
|
const state = RegistrationStateV2();
|
|
|
|
expect(state.firstName, '');
|
|
expect(state.lastName, '');
|
|
expect(state.email, '');
|
|
expect(state.phone, '');
|
|
expect(state.gender, '');
|
|
expect(state.password, '');
|
|
expect(state.weight, 0);
|
|
expect(state.height, 0);
|
|
expect(state.activityCoefficient, 1.2);
|
|
expect(state.birthday, isNull);
|
|
expect(state.isFirstNameValid, isTrue);
|
|
expect(state.isLastNameValid, isTrue);
|
|
expect(state.isEmailValid, isTrue);
|
|
expect(state.isPhoneValid, isTrue);
|
|
expect(state.isGenderValid, isTrue);
|
|
expect(state.isWeightValid, isTrue);
|
|
expect(state.isHeightValid, isTrue);
|
|
expect(state.isActivityCoefficientValid, isTrue);
|
|
expect(state.isBirthdayValid, isTrue);
|
|
expect(state.step, 0);
|
|
expect(state.emailDisplayError, '');
|
|
expect(state.phoneDisplayError, '');
|
|
expect(state.dateOfBirthDisplayError, '');
|
|
expect(state.registrationError, isNull);
|
|
});
|
|
|
|
test('creates instance with custom values', () {
|
|
final birthday = DateTime(1990, 1, 1);
|
|
final state = RegistrationStateV2(
|
|
firstName: 'John',
|
|
lastName: 'Doe',
|
|
email: 'john@example.com',
|
|
phone: '+1234567890',
|
|
gender: 'male',
|
|
password: 'password123',
|
|
weight: 70,
|
|
height: 175,
|
|
activityCoefficient: 1.5,
|
|
birthday: birthday,
|
|
isFirstNameValid: false,
|
|
step: 2,
|
|
registrationError: 'Error occurred',
|
|
);
|
|
|
|
expect(state.firstName, 'John');
|
|
expect(state.lastName, 'Doe');
|
|
expect(state.email, 'john@example.com');
|
|
expect(state.phone, '+1234567890');
|
|
expect(state.gender, 'male');
|
|
expect(state.password, 'password123');
|
|
expect(state.weight, 70);
|
|
expect(state.height, 175);
|
|
expect(state.activityCoefficient, 1.5);
|
|
expect(state.birthday, birthday);
|
|
expect(state.isFirstNameValid, isFalse);
|
|
expect(state.step, 2);
|
|
expect(state.registrationError, 'Error occurred');
|
|
});
|
|
|
|
test('copyWith creates new instance with updated values', () {
|
|
const original = RegistrationStateV2();
|
|
final updated = original.copyWith(
|
|
firstName: 'Jane',
|
|
email: 'jane@example.com',
|
|
step: 1,
|
|
);
|
|
|
|
expect(updated.firstName, 'Jane');
|
|
expect(updated.email, 'jane@example.com');
|
|
expect(updated.step, 1);
|
|
expect(updated.lastName, original.lastName);
|
|
expect(updated.phone, original.phone);
|
|
});
|
|
});
|
|
}
|
|
|