yumi-flutter/test/sc_cp_relation_pair_utils_test.dart
2026-05-22 17:35:49 +08:00

66 lines
2.0 KiB
Dart

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_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);
});
});
}