Files
eatvio_app/test/features/chat/models/chat_user_model_test.dart

63 lines
1.7 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/chat/models/chat_user_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('ChatUserModel', () {
test('создает ChatUserModel с правильными значениями', () {
const model = ChatUserModel(
id: 1,
name: 'User Name',
slug: 'user-slug',
profilePhotoUrl: 'https://example.com/photo.jpg',
);
expect(model.id, 1);
expect(model.name, 'User Name');
expect(model.slug, 'user-slug');
expect(model.profilePhotoUrl, 'https://example.com/photo.jpg');
});
test('создает ChatUserModel без фото', () {
const model = ChatUserModel(
id: 1,
name: 'User Name',
slug: 'user-slug',
profilePhotoUrl: null,
);
expect(model.profilePhotoUrl, isNull);
});
test('fromJson создает ChatUserModel из JSON', () {
final json = {
'id': 1,
'name': 'User Name',
'slug': 'user-slug',
'profile_photo_url': 'https://example.com/photo.jpg',
};
final model = ChatUserModel.fromJson(json);
expect(model.id, 1);
expect(model.name, 'User Name');
expect(model.slug, 'user-slug');
expect(model.profilePhotoUrl, 'https://example.com/photo.jpg');
});
test('fromJson создает ChatUserModel из JSON без фото', () {
final json = {
'id': 1,
'name': 'User Name',
'slug': 'user-slug',
};
final model = ChatUserModel.fromJson(json);
expect(model.id, 1);
expect(model.name, 'User Name');
expect(model.profilePhotoUrl, isNull);
});
});
}