Files
eatvio_app/test/features/auth/models/yandex_profile_model_test.dart

75 lines
2.1 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:eatvio_app/features/auth/models/yandex_profile_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('YandexProfileModel', () {
test('создает YandexProfileModel с правильными значениями', () {
final phoneData = YandexPhoneData(id: 1, number: '+79001234567');
final model = YandexProfileModel(
id: '123',
login: 'test@yandex.ru',
birthday: '1990-01-01',
clientId: 'client-123',
displayName: 'Display Name',
realName: 'Real Name',
firstName: 'First',
lastName: 'Last',
sex: 'male',
defaultEmail: 'test@yandex.ru',
defaultPhone: phoneData,
);
expect(model.id, '123');
expect(model.login, 'test@yandex.ru');
expect(model.defaultPhone.number, '+79001234567');
});
test('fromJson создает YandexProfileModel из JSON', () {
final json = {
'id': '123',
'login': 'test@yandex.ru',
'birthday': '1990-01-01',
'client_id': 'client-123',
'display_name': 'Display Name',
'real_name': 'Real Name',
'first_name': 'First',
'last_name': 'Last',
'sex': 'male',
'default_email': 'test@yandex.ru',
'default_phone': {
'id': 1,
'number': '+79001234567',
},
};
final model = YandexProfileModel.fromJson(json);
expect(model.id, '123');
expect(model.login, 'test@yandex.ru');
expect(model.defaultPhone.number, '+79001234567');
});
});
group('YandexPhoneData', () {
test('создает YandexPhoneData с правильными значениями', () {
final phoneData = YandexPhoneData(id: 1, number: '+79001234567');
expect(phoneData.id, 1);
expect(phoneData.number, '+79001234567');
});
test('fromJson создает YandexPhoneData из JSON', () {
final json = {
'id': 1,
'number': '+79001234567',
};
final phoneData = YandexPhoneData.fromJson(json);
expect(phoneData.id, 1);
expect(phoneData.number, '+79001234567');
});
});
}