forked from eatvio/eatvio_app
63 lines
1.7 KiB
Dart
63 lines
1.7 KiB
Dart
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);
|
||
});
|
||
});
|
||
}
|
||
|