forked from eatvio/eatvio_app
feat(token_storage): add clearCache method for testing and ensure fresh state in tests
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user