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 creates ChatUserModel from JSON', () { final json = { 'id': 1, 'name': 'User Name', 'slug': 'user-slug', 'profile_photo_url': 'https://example.com/photo.jpg', 'is_online': true, 'last_seen_text': 'был(а) недавно', }; 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'); expect(model.isOnline, isTrue); expect(model.lastSeenText, 'был(а) недавно'); }); 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); }); test('toJson serializes ChatUserModel correctly', () { const model = ChatUserModel( id: 1, name: 'User Name', slug: 'user-slug', profilePhotoUrl: 'https://example.com/photo.jpg', ); final json = model.toJson(); expect(json['id'], 1); expect(json['name'], 'User Name'); expect(json['slug'], 'user-slug'); expect(json['profile_photo_url'], 'https://example.com/photo.jpg'); }); test('toJson handles null profilePhotoUrl', () { const model = ChatUserModel( id: 1, name: 'User Name', slug: 'user-slug', profilePhotoUrl: null, ); final json = model.toJson(); expect(json['profile_photo_url'], isNull); }); }); }