You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.9 KiB
49 lines
1.9 KiB
import 'package:eaimar/core/utils/id_verify_guard.dart';
|
|
import 'package:eaimar/data/models/channel_app_model.dart';
|
|
import 'package:eaimar/data/services/version_update_service.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
/// 实名认证的显隐与游客登录同一个口子(2026-09-23):服务端下发 idverify,
|
|
/// 隐藏时 IdVerifyGuard 整个失效、所有功能不受实名限制。
|
|
void main() {
|
|
Map<String, dynamic> base() => {
|
|
'channel': 100,
|
|
'description': '',
|
|
'version': '1.0.3',
|
|
'paychannels': '',
|
|
};
|
|
|
|
group('AppInfo.idverify', () {
|
|
test('读服务端下发的 idverify', () {
|
|
expect(AppInfo.fromJson({...base(), 'tourists': false, 'idverify': true}).idverify, isTrue);
|
|
expect(AppInfo.fromJson({...base(), 'tourists': true, 'idverify': false}).idverify, isFalse);
|
|
});
|
|
test('老服务端没有 idverify 字段时退回 tourists', () {
|
|
expect(AppInfo.fromJson({...base(), 'tourists': true}).idverify, isTrue);
|
|
expect(AppInfo.fromJson({...base(), 'tourists': false}).idverify, isFalse);
|
|
});
|
|
test('两个字段都没有 = 隐藏', () {
|
|
expect(AppInfo.fromJson(base()).idverify, isFalse);
|
|
});
|
|
});
|
|
|
|
group('IdVerifyGuard', () {
|
|
tearDown(() => VersionUpdateService.showIdVerify.value = false);
|
|
|
|
test('实名隐藏时闸门放行、不弹窗', () {
|
|
VersionUpdateService.showIdVerify.value = false;
|
|
expect(IdVerifyGuard.entryShown, isFalse);
|
|
expect(IdVerifyGuard.required, isFalse);
|
|
expect(IdVerifyGuard.blocked(), isFalse);
|
|
});
|
|
|
|
test('默认值是隐藏(拿不到配置时放行)', () {
|
|
expect(VersionUpdateService.showIdVerify.value, isFalse);
|
|
});
|
|
|
|
test('实名显示时 entryShown 跟着变', () {
|
|
VersionUpdateService.showIdVerify.value = true;
|
|
expect(IdVerifyGuard.entryShown, isTrue);
|
|
});
|
|
});
|
|
}
|
|
|