import 'package:flutter_test/flutter_test.dart'; import 'package:yumi/shared/business_logic/models/res/login_res.dart'; import 'package:yumi/shared/tools/sc_cp_relation_level_utils.dart'; import 'package:yumi/shared/tools/sc_cp_relation_pair_utils.dart'; void main() { group('scCpRelationTypeBetweenProfiles', () { test('detects cp relation from either adjacent profile', () { final left = SocialChatUserProfile( id: '100', account: 'left', cpList: [ CPRes( meUserId: '100', meAccount: 'left', cpUserId: '200', cpAccount: 'right', relationType: 'CP', levelText: 'Lv.3 Sweet', ), ], ); final right = SocialChatUserProfile(id: '200', account: 'right'); expect(scCpRelationTypeBetweenProfiles(left, right), 'CP'); expect(scCpRelationTypeBetweenProfiles(right, left), 'CP'); expect(scCpRelationInfoBetweenProfiles(left, right)?.cpLevel, 3); }); test('detects brother and sister close-friend relations', () { final brotherLeft = SocialChatUserProfile( id: '100', closeFriendList: [ CPRes(meUserId: '100', cpUserId: '200', relationType: 'bro'), ], ); final brotherRight = SocialChatUserProfile(id: '200'); final sisterLeft = SocialChatUserProfile(id: '300'); final sisterRight = SocialChatUserProfile( id: '400', closeFriendList: [ CPRes(meUserId: '300', cpUserId: '400', relationType: 'sis'), ], ); expect( scCpRelationTypeBetweenProfiles(brotherLeft, brotherRight), 'BROTHER', ); expect( scCpRelationTypeBetweenProfiles(sisterLeft, sisterRight), 'SISTERS', ); }); test('does not match unrelated profiles', () { final left = SocialChatUserProfile( id: '100', cpList: [CPRes(meUserId: '100', cpUserId: '200', relationType: 'CP')], ); final right = SocialChatUserProfile(id: '300'); expect(scCpRelationTypeBetweenProfiles(left, right), isNull); }); }); group('scCpRelationLevelTextFromCabin', () { test('uses cp value and config thresholds for current level text', () { final cabin = SCCpCabinRes( cpVal: 1200, cpCabinConfigCO: const [ {'level': 1, 'levelName': 'Simple Love', 'requiredCpValue': 0}, {'level': 2, 'levelName': 'Sweet Love', 'requiredCpValue': 1000}, {'level': 3, 'levelName': 'Deep Love', 'requiredCpValue': 3000}, ], currentCpCabinConfigCO: const {'level': 1, 'levelName': 'Simple Love'}, ); expect(scCpRelationLevelTextFromCabin(cabin), 'Lv.2 Sweet Love'); }); }); }