forked from eatvio/eatvio_app
55 lines
1.6 KiB
Dart
55 lines
1.6 KiB
Dart
import 'package:eatvio_app/features/menu/models/blocked_users_model.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
group('BlockedUsersModel', () {
|
|
test('fromJson parses profilesList correctly', () {
|
|
final json = {
|
|
'data': [
|
|
{
|
|
'id': 1,
|
|
'name': 'User 1',
|
|
'email': 'user1@example.com',
|
|
'phone_confirmation_state': 'confirmed',
|
|
'is_public_profile': true,
|
|
'is_blocked_by_me': false,
|
|
'is_blocked_by_author': false,
|
|
'is_blocked_by_user': false,
|
|
'is_entity_subscribed_by_me': false,
|
|
'slug': 'user-1',
|
|
'profile_photo_url': 'photo1.jpg',
|
|
'roles': ['user'],
|
|
'badges': [],
|
|
'subscriptions': [],
|
|
'subscribers': [],
|
|
},
|
|
],
|
|
};
|
|
|
|
final model = BlockedUsersModel.fromJson(json);
|
|
|
|
expect(model.profilesList.length, 1);
|
|
expect(model.profilesList.first.id, 1);
|
|
expect(model.profilesList.first.name, 'User 1');
|
|
});
|
|
|
|
test('fromJson handles empty profilesList', () {
|
|
final json = {'data': []};
|
|
|
|
final model = BlockedUsersModel.fromJson(json);
|
|
|
|
expect(model.profilesList, isEmpty);
|
|
});
|
|
|
|
test('toJson serializes profilesList correctly', () {
|
|
// Note: This test verifies the structure, actual serialization depends on ProfileModel
|
|
const model = BlockedUsersModel(profilesList: []);
|
|
|
|
final json = model.toJson();
|
|
|
|
expect(json.containsKey('data'), isTrue);
|
|
expect(json['data'], isA<List>());
|
|
});
|
|
});
|
|
}
|