@@ -4,23 +4,24 @@ import 'package:json_cache/json_cache.dart';
44import 'flutter_secure_storage_mock.dart' ;
55
66void main () {
7- group ('JsonCacheSecStorage ' , () {
7+ group ('JsonCacheFlutterSecureStorage ' , () {
88 test ('clear, value, refresh' , () async {
99 final secStorageMock = FlutterSecureStorageMock ();
10- final JsonCacheSecStorage secCache = JsonCacheSecStorage (secStorageMock);
10+ final JsonCacheFlutterSecureStorage flutterSecureCache =
11+ JsonCacheFlutterSecureStorage (secStorageMock);
1112 const profKey = 'profile' ;
1213 const profData = < String , Object > {'id' : 1 , 'name' : 'John Due' };
13- await secCache .refresh (profKey, profData);
14+ await flutterSecureCache .refresh (profKey, profData);
1415 expect (secStorageMock.writeInvokations, 1 );
1516
16- var prof = await secCache .value (profKey);
17+ var prof = await flutterSecureCache .value (profKey);
1718 expect (prof, profData);
1819 expect (secStorageMock.readInvokations, 1 );
1920
20- await secCache .clear ();
21+ await flutterSecureCache .clear ();
2122 expect (secStorageMock.deleteAllInvokations, 1 );
2223
23- prof = await secCache .value (profKey);
24+ prof = await flutterSecureCache .value (profKey);
2425 expect (prof, isNull);
2526 expect (secStorageMock.readInvokations, 2 );
2627 });
@@ -34,52 +35,54 @@ void main() {
3435 'notifications' : {'enabled' : true }
3536 };
3637 final secStorageMock = FlutterSecureStorageMock ();
37- final JsonCacheSecStorage secCache = JsonCacheSecStorage (secStorageMock);
38+ final JsonCacheFlutterSecureStorage flutterSecureCache =
39+ JsonCacheFlutterSecureStorage (secStorageMock);
3840 // update data
39- await secCache .refresh (profKey, profData);
40- await secCache .refresh (prefKey, prefData);
41+ await flutterSecureCache .refresh (profKey, profData);
42+ await flutterSecureCache .refresh (prefKey, prefData);
4143
4244 // test for `true`
43- expect (await secCache .contains (profKey), true );
44- expect (await secCache .contains (prefKey), true );
45+ expect (await flutterSecureCache .contains (profKey), true );
46+ expect (await flutterSecureCache .contains (prefKey), true );
4547
4648 // test for `false`
47- expect (await secCache .contains ('a key' ), false );
48- await secCache .remove (profKey);
49- expect (await secCache .contains (profKey), false );
50- await secCache .remove (prefKey);
51- expect (await secCache .contains (prefKey), false );
49+ expect (await flutterSecureCache .contains ('a key' ), false );
50+ await flutterSecureCache .remove (profKey);
51+ expect (await flutterSecureCache .contains (profKey), false );
52+ await flutterSecureCache .remove (prefKey);
53+ expect (await flutterSecureCache .contains (prefKey), false );
5254 });
5355 test ('remove' , () async {
5456 final secStorageMock = FlutterSecureStorageMock ();
55- final JsonCacheSecStorage secCache = JsonCacheSecStorage (secStorageMock);
57+ final JsonCacheFlutterSecureStorage flutterSecureCache =
58+ JsonCacheFlutterSecureStorage (secStorageMock);
5659 const profKey = 'profile' ;
5760 const prefKey = 'preferences' ;
5861 final profData = < String , Object > {'id' : 1 , 'name' : 'John Due' };
5962 final prefData = < String , Object > {
6063 'theme' : 'dark' ,
6164 'notifications' : {'enabled' : true }
6265 };
63- await secCache .refresh (profKey, profData);
64- await secCache .refresh (prefKey, prefData);
66+ await flutterSecureCache .refresh (profKey, profData);
67+ await flutterSecureCache .refresh (prefKey, prefData);
6568 expect (secStorageMock.writeInvokations, 2 );
6669
67- var prof = await secCache .value (profKey);
70+ var prof = await flutterSecureCache .value (profKey);
6871 expect (prof, profData);
6972 expect (secStorageMock.readInvokations, 1 );
7073
71- await secCache .remove (profKey);
74+ await flutterSecureCache .remove (profKey);
7275 expect (secStorageMock.deleteInvokations, 1 );
73- prof = await secCache .value (profKey);
76+ prof = await flutterSecureCache .value (profKey);
7477 expect (prof, isNull);
7578 expect (secStorageMock.readInvokations, 2 );
7679
77- var pref = await secCache .value (prefKey);
80+ var pref = await flutterSecureCache .value (prefKey);
7881 expect (pref, prefData);
7982 expect (secStorageMock.readInvokations, 3 );
80- await secCache .remove (prefKey);
83+ await flutterSecureCache .remove (prefKey);
8184 expect (secStorageMock.deleteInvokations, 2 );
82- pref = await secCache .value (prefKey);
85+ pref = await flutterSecureCache .value (prefKey);
8386 expect (pref, isNull);
8487 expect (secStorageMock.readInvokations, 4 );
8588 });
0 commit comments