68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:yumi/app/constants/sc_room_msg_type.dart';
|
|
import 'package:yumi/services/audio/rtm_manager.dart';
|
|
import 'package:yumi/shared/data_sources/models/message/sc_floating_message.dart';
|
|
import 'package:yumi/shared/tools/sc_cp_relation_broadcast_assets.dart';
|
|
|
|
void main() {
|
|
test(
|
|
'converts backend CP_RELATION_BROADCAST to a global floating message',
|
|
() {
|
|
final message = buildCpRelationBroadcastFloatingMessage({
|
|
'type': SCRoomMsgType.cpRelationBroadcast,
|
|
'relationType': 'BROTHERS',
|
|
'msg': 'Alice与Bob结为兄弟',
|
|
'applyId': '9001',
|
|
'user': {
|
|
'userId': '1001',
|
|
'account': 'alice',
|
|
'userNickname': 'Alice',
|
|
'userAvatar': 'alice.png',
|
|
},
|
|
'cpUser': {
|
|
'userId': '1002',
|
|
'account': 'bob',
|
|
'userNickname': 'Bob',
|
|
'userAvatar': 'bob.png',
|
|
},
|
|
});
|
|
|
|
expect(message, isNotNull);
|
|
expect(message!.type, scCpRelationBroadcastFloatingType);
|
|
expect(message.broadcastScope, SCFloatingMessage.broadcastScopeRegion);
|
|
expect(message.userId, '1001');
|
|
expect(message.toUserId, '1002');
|
|
expect(message.userName, 'Alice');
|
|
expect(message.toUserName, 'Bob');
|
|
expect(message.giftTab, 'BROTHER');
|
|
expect(message.giftId, 'RELATION_ESTABLISHED');
|
|
expect(message.gameId, '9001');
|
|
expect(message.displayText, 'Alice与Bob结为兄弟');
|
|
},
|
|
);
|
|
|
|
test('suppresses the old room relation-established notice only', () {
|
|
expect(
|
|
shouldSuppressRoomCpRelationNotice(
|
|
messageType: SCRoomMsgType.cpSystemNotice,
|
|
noticeAction: 'RELATION_ESTABLISHED',
|
|
),
|
|
isTrue,
|
|
);
|
|
expect(
|
|
shouldSuppressRoomCpRelationNotice(
|
|
messageType: SCRoomMsgType.cpSystemNotice,
|
|
noticeAction: 'RELATION_JOINED_ROOM',
|
|
),
|
|
isFalse,
|
|
);
|
|
expect(
|
|
shouldSuppressRoomCpRelationNotice(
|
|
messageType: SCRoomMsgType.cpSystemNotice,
|
|
noticeAction: 'RELATION_REJECTED',
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
}
|