import 'package:flutter_test/flutter_test.dart'; import 'package:yumi/shared/business_logic/models/res/sc_broad_cast_luck_gift_push.dart'; void main() { group('lucky gift reward merge', () { test('accumulates reward amount and keeps the strongest multiplier', () { final first = SCBroadCastLuckGiftPush.fromJson({ 'type': 'GAME_LUCKY_GIFT', 'data': { 'roomId': 'room-1', 'giftId': 'gift-1', 'sendUserId': 'sender-1', 'acceptUserId': 'receiver-1', 'awardAmount': 5000, 'giftQuantity': 1, 'multiple': 10, 'multipleType': 'WIN', }, }); final second = SCBroadCastLuckGiftPush.fromJson({ 'type': 'GAME_LUCKY_GIFT', 'data': { 'roomId': 'room-1', 'giftId': 'gift-1', 'sendUserId': 'sender-1', 'acceptUserId': 'receiver-1', 'awardAmount': 12000, 'giftQuantity': 2, 'multiple': 30, 'multipleType': 'BIG_WIN', }, }); final merged = first.mergeReward(second); expect(merged.data?.awardAmount, 17000); expect(merged.data?.giftQuantity, 3); expect(merged.data?.multiple, 30); expect(merged.data?.multipleType, 'BIG_WIN'); }); test('parses global lucky gift win payload aliases', () { final message = SCBroadCastLuckGiftPush.fromJson({ 'type': 'GAME_LUCKY_GIFT', 'data': { 'acceptUserId': '123456', 'businessId': 'admin-sim-lucky-gift-1779714977048', 'giftId': '1', 'giftQuantity': 1, 'globalNews': true, 'msg': '123456 play lucky_gift get x 10 win 1000 coins!!!', 'multipleType': 'WIN', 'orderId': 'admin-sim-order-1779714977048', 'roomId': '123456', 'senderUserId': '123456', 'userId': '123456', 'winAmount': 1000, 'winMultiple': 10, }, }); expect(message.data?.sendUserId, '123456'); expect(message.data?.awardAmount, 1000); expect(message.data?.multiple, 10); expect(message.data?.shouldShowGlobalNews, isTrue); expect(message.data?.businessId, 'admin-sim-lucky-gift-1779714977048'); expect( message.data?.msg, '123456 play lucky_gift get x 10 win 1000 coins!!!', ); }); }); }