fix:参考金值,研听,研值工程通用通用工程公共能力,重点对比网络请求、登录认证、状态管理、本地存储、WebView、推送、版本更新、一键登录、主题/UI 等模块,确定后续统一整改方案
This commit is contained in:
1 parent
6997a65c96
commit
d364c6d908
46 files changed
+2060
-395
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:jinzhi_flutter_app/common/storage/preferences_storage.dart';
|
||||
import 'package:jinzhi_flutter_app/features/assets/data/mock_asset_repository.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() => SharedPreferences.setMockInitialValues({}));
|
||||
|
||||
test('account deletion stays empty after repository recreation', () async {
|
||||
final preferences = PreferencesStorage(
|
||||
await SharedPreferences.getInstance(),
|
||||
);
|
||||
final repository = MockAssetRepository(preferences);
|
||||
final accountScope = MockAssetRepository.accountScope(userId: 'user-1');
|
||||
final initial = repository.loadHoldings(accountScope);
|
||||
expect(initial, isNotEmpty);
|
||||
expect(
|
||||
repository.loadHoldings(MockAssetRepository.guestAccountScope),
|
||||
isNotEmpty,
|
||||
);
|
||||
await repository.saveHoldings(accountScope, initial);
|
||||
|
||||
await repository.deleteAccountHoldings(accountScope);
|
||||
final recreated = MockAssetRepository(preferences);
|
||||
|
||||
expect(recreated.loadHoldings(accountScope), isEmpty);
|
||||
expect(
|
||||
recreated.loadHoldings(MockAssetRepository.guestAccountScope),
|
||||
isEmpty,
|
||||
);
|
||||
});
|
||||
|
||||
test('holdings are isolated by account and deletion is scoped', () async {
|
||||
final preferences = PreferencesStorage(
|
||||
await SharedPreferences.getInstance(),
|
||||
);
|
||||
final repository = MockAssetRepository(preferences);
|
||||
final first = MockAssetRepository.accountScope(userId: 'user-1');
|
||||
final second = MockAssetRepository.accountScope(userId: 'user-2');
|
||||
final firstHoldings = repository.loadHoldings(first);
|
||||
final secondHoldings = repository.loadHoldings(second);
|
||||
await repository.saveHoldings(first, firstHoldings.take(1).toList());
|
||||
await repository.saveHoldings(second, secondHoldings.take(2).toList());
|
||||
|
||||
await repository.deleteAccountHoldings(first);
|
||||
|
||||
expect(repository.loadHoldings(first), isEmpty);
|
||||
expect(repository.loadHoldings(second), hasLength(2));
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user