yumi-flutter/test/sc_cp_rights_config_res_test.dart
2026-05-22 19:32:01 +08:00

77 lines
2.4 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:yumi/shared/business_logic/models/res/sc_cp_rights_config_res.dart';
void main() {
group('SCCpRightsConfigRes', () {
test('parses the updated rights config body', () {
final config = SCCpRightsConfigRes.fromJson({
'relationType': 'CP',
'cpUserId': null,
'relationshipStatus': 'NONE',
'intimacyValue': 0,
'dismissConsumeGold': 88,
'levels': [
{
'level': 1,
'levelName': 'CP 1级',
'requiredIntimacyValue': 0,
'unlocked': false,
'rights': [
{
'rightKey': 'CP_CABIN_LEVEL_1',
'icon': null,
'title': 'CP 1级',
'desc': 'Unlock when intimacy reaches 0',
'unlocked': false,
},
],
},
],
});
expect(config.relationType, 'CP');
expect(config.cpUserId, isNull);
expect(config.relationshipStatus, 'NONE');
expect(config.intimacyValue, 0);
expect(config.dismissConsumeGold, 88);
expect(config.levels, hasLength(1));
expect(config.levels.first.levelName, 'CP 1级');
expect(config.levels.first.requiredIntimacyValue, 0);
expect(config.levels.first.unlocked, false);
expect(config.levels.first.rights.first.rightKey, 'CP_CABIN_LEVEL_1');
expect(config.levels.first.rights.first.title, 'CP 1级');
});
test('also accepts a full response envelope', () {
final config = SCCpRightsConfigRes.fromJson({
'status': true,
'errorCode': 0,
'body': {
'relationType': 'SISTERS',
'cpUserId': 123,
'relationshipStatus': 'ACTIVE',
'intimacyValue': 1200,
'dismissConsumeGold': 120,
'levels': [
{
'level': 2,
'levelName': 'Sisters 2',
'requiredIntimacyValue': 1000,
'unlocked': true,
'rights': [],
},
],
},
});
expect(config.relationType, 'SISTERS');
expect(config.cpUserId, '123');
expect(config.relationshipStatus, 'ACTIVE');
expect(config.intimacyValue, 1200);
expect(config.dismissConsumeGold, 120);
expect(config.levels.first.level, 2);
expect(config.levels.first.unlocked, true);
});
});
}