11import 'dart:io' ;
2+
23import 'package:flutter_test/flutter_test.dart' ;
34import 'package:json_cache/src/json_cache_safe_local_storage.dart' ;
45import 'package:safe_local_storage/safe_local_storage.dart' ;
@@ -109,6 +110,16 @@ void main() {
109110 // Check for multiple data.
110111 expect (await jsonCacheSafeLocalStorage.contains (profKey), true );
111112 expect (await jsonCacheSafeLocalStorage.contains (prefKey), true );
113+
114+ // Remove data from the cache.
115+ await jsonCacheSafeLocalStorage.remove (profKey);
116+ expect (await jsonCacheSafeLocalStorage.contains (profKey), false );
117+ expect (await jsonCacheSafeLocalStorage.contains (prefKey), true );
118+
119+ // Remove data from the cache.
120+ await jsonCacheSafeLocalStorage.remove (prefKey);
121+ expect (await jsonCacheSafeLocalStorage.contains (profKey), false );
122+ expect (await jsonCacheSafeLocalStorage.contains (prefKey), false );
112123 },
113124 );
114125
@@ -119,12 +130,15 @@ void main() {
119130 await jsonCacheSafeLocalStorage.refresh (profKey, profData);
120131 await jsonCacheSafeLocalStorage.refresh (prefKey, prefData);
121132
122- // Clear it.
133+ // Clear it. All data should be deleted with the file.
123134 await jsonCacheSafeLocalStorage.clear ();
124135
125136 // No data should remain in the cache.
126137 final cachedValue = await jsonCacheSafeLocalStorage.value (profKey);
127138 expect (cachedValue, isNull);
139+
140+ // Insert a single piece of data into the cache. This refresh avoids errors on operational systems.
141+ await jsonCacheSafeLocalStorage.refresh (profKey, profData);
128142 },
129143 );
130144 },
@@ -133,7 +147,6 @@ void main() {
133147 tearDown (
134148 () async {
135149 await storage.delete ();
136- await tempDir.delete_ ();
137150 },
138151 );
139152}
0 commit comments