feat(token_storage): add clearCache method for testing and ensure fresh state in tests

This commit is contained in:
mso7nueh
2026-01-14 13:02:24 +03:00
parent d206e7ec12
commit 41e96c63c6
3 changed files with 23 additions and 32 deletions

View File

@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';
abstract class TokenStorage {
@@ -8,6 +9,13 @@ abstract class TokenStorage {
return _cachedPrefs!;
}
/// Clears the cached SharedPreferences instance.
/// This is primarily used for testing to ensure fresh state between tests.
@visibleForTesting
static void clearCache() {
_cachedPrefs = null;
}
static Future<bool> haveTokenInStorage() async {
try {
final sharedPreferences = await _getPrefs();