yumi-flutter/test/user_profile_manager_room_card_session_test.dart
2026-05-25 17:05:30 +08:00

45 lines
1.5 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:yumi/services/auth/user_profile_manager.dart';
import 'package:yumi/shared/business_logic/models/res/login_res.dart';
import 'package:yumi/shared/business_logic/models/res/room_user_card_res.dart';
void main() {
test('stale room card dispose does not clear the active card session', () {
final manager = SocialChatUserProfileManager();
final staleSession = manager.beginRoomUserCardSession();
final activeSession = manager.beginRoomUserCardSession();
manager.userCardInfo = RoomUserCardRes(
userProfile: SocialChatUserProfile(id: 'active-user'),
);
manager.clearRoomUserCard(sessionSerial: staleSession);
expect(manager.userCardInfo?.userProfile?.id, 'active-user');
manager.clearRoomUserCard(sessionSerial: activeSession);
expect(manager.userCardInfo, isNull);
});
test('removeLoadedCpRelation removes matching close friend relation', () {
final manager = SocialChatUserProfileManager();
manager.userProfile = SocialChatUserProfile(
id: '100',
closeFriendList: [
CPRes(meUserId: '100', cpUserId: '200', relationType: 'BROTHER'),
CPRes(meUserId: '100', cpUserId: '300', relationType: 'SISTERS'),
],
);
manager.removeLoadedCpRelation(
userId: '100',
peerUserId: '200',
relationType: 'BROTHER',
);
expect(manager.userProfile?.closeFriendList, hasLength(1));
expect(manager.userProfile?.closeFriendList?.single.cpUserId, '300');
});
}