import 'package:flutter_test/flutter_test.dart'; import 'package:yumi/shared/business_logic/models/res/sc_user_badge_res.dart'; void main() { group('SCUserBadgeRes honor wall badges', () { test('uses short badges only and sorts newest first', () { final result = SCUserBadgeRes.fromJson({ 'longBadges': [ { 'id': 'vip', 'type': 'LONG', 'sourceType': 'VIP', 'selectUrl': 'https://example.com/vip.png', 'updateTime': 3000, }, ], 'shortBadges': [ { 'id': 'old', 'type': 'SHORT', 'sourceType': 'ACTIVITY', 'selectUrl': 'https://example.com/old.png', 'updateTime': 1000, }, { 'id': 'new', 'type': 'SHORT', 'sourceType': 'ACHIEVEMENT', 'selectUrl': 'https://example.com/new.png', 'updateTime': 2000, }, ], }); expect(result.displayBadges.map((badge) => badge.id), [ 'vip', 'old', 'new', ]); expect(result.honorWallBadges.map((badge) => badge.id), ['new', 'old']); }); test('filters long and vip badges from legacy mixed badges', () { final result = SCUserBadgeRes.fromJson({ 'badges': [ { 'id': 'long', 'type': 'LONG', 'selectUrl': 'https://example.com/long.png', 'updateTime': 3000, }, { 'id': 'vip', 'type': 'VIP', 'sourceType': 'VIP', 'selectUrl': 'https://example.com/vip.png', 'updateTime': 2500, }, { 'id': 'activity', 'type': 'ACTIVITY', 'sourceType': 'ACTIVITY', 'selectUrl': 'https://example.com/activity.png', 'updateTime': 1000, }, { 'id': 'achievement', 'type': 'ACHIEVEMENT', 'sourceType': 'ACHIEVEMENT', 'selectUrl': 'https://example.com/achievement.png', 'updateTime': 2000, }, ], }); expect(result.honorWallBadges.map((badge) => badge.id), [ 'achievement', 'activity', ]); }); }); }