forked from eatvio/eatvio_app
feat(tests): updated tests coverage to 66.5%
This commit is contained in:
@@ -48,6 +48,56 @@ void main() {
|
||||
expect(model.login, 'test@yandex.ru');
|
||||
expect(model.defaultPhone.number, '+79001234567');
|
||||
});
|
||||
|
||||
test('fromJson handles null sex field', () {
|
||||
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': null,
|
||||
'default_email': 'test@yandex.ru',
|
||||
'default_phone': {
|
||||
'id': 1,
|
||||
'number': '+79001234567',
|
||||
},
|
||||
};
|
||||
|
||||
final model = YandexProfileModel.fromJson(json);
|
||||
|
||||
expect(model.sex, isNull);
|
||||
});
|
||||
|
||||
test('toJson serializes YandexProfileModel correctly', () {
|
||||
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,
|
||||
);
|
||||
|
||||
final json = model.toJson();
|
||||
|
||||
expect(json['id'], '123');
|
||||
expect(json['login'], 'test@yandex.ru');
|
||||
expect(json['client_id'], 'client-123');
|
||||
expect(json['first_name'], 'First');
|
||||
expect(json['last_name'], 'Last');
|
||||
expect(json['sex'], 'male');
|
||||
expect(json.containsKey('default_phone'), isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
group('YandexPhoneData', () {
|
||||
@@ -69,6 +119,15 @@ void main() {
|
||||
expect(phoneData.id, 1);
|
||||
expect(phoneData.number, '+79001234567');
|
||||
});
|
||||
|
||||
test('toJson serializes YandexPhoneData correctly', () {
|
||||
final phoneData = YandexPhoneData(id: 1, number: '+79001234567');
|
||||
|
||||
final json = phoneData.toJson();
|
||||
|
||||
expect(json['id'], 1);
|
||||
expect(json['number'], '+79001234567');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user