1
+ import 'package:core/utils/file_utils.dart' ;
2
+ import 'package:core/utils/platform_info.dart' ;
3
+ import 'package:flutter_secure_storage/flutter_secure_storage.dart' ;
4
+ import 'package:flutter_test/flutter_test.dart' ;
5
+ import 'package:get/instance_manager.dart' ;
6
+ import 'package:mockito/annotations.dart' ;
7
+ import 'package:shared_preferences/shared_preferences.dart' ;
8
+ import 'package:tmail_ui_user/features/login/data/local/token_oidc_cache_manager.dart' ;
9
+ import 'package:tmail_ui_user/features/login/data/local/web_token_oidc_cache_manager.dart' ;
10
+ import 'package:tmail_ui_user/main/bindings/local/local_bindings.dart' ;
11
+
12
+ import 'local_bindings_test.mocks.dart' ;
13
+
14
+ @GenerateNiceMocks ([
15
+ MockSpec <FlutterSecureStorage >(),
16
+ MockSpec <SharedPreferences >(),
17
+ MockSpec <FileUtils >(),
18
+ ])
19
+ void main () {
20
+ late LocalBindings localBindings;
21
+
22
+ setUp (() {
23
+ localBindings = LocalBindings ();
24
+ Get .put <FlutterSecureStorage >(MockFlutterSecureStorage ());
25
+ Get .put <SharedPreferences >(MockSharedPreferences ());
26
+ Get .put <FileUtils >(MockFileUtils ());
27
+ });
28
+
29
+ group ('local bindings test:' , () {
30
+ test (
31
+ 'should inject WebTokenOidcCacheManager '
32
+ 'when platform is web' ,
33
+ () {
34
+ // arrange
35
+ PlatformInfo .isTestingForWeb = true ;
36
+ localBindings.dependencies ();
37
+
38
+ // act
39
+ final cacheManager = Get .find <TokenOidcCacheManager >();
40
+
41
+ // assert
42
+ expect (cacheManager, isInstanceOf <WebTokenOidcCacheManager >());
43
+ PlatformInfo .isTestingForWeb = false ;
44
+ });
45
+
46
+ test (
47
+ 'should inject TokenOidcCacheManager '
48
+ 'when platform is not web (default)' ,
49
+ () {
50
+ // arrange
51
+ localBindings.dependencies ();
52
+
53
+ // act
54
+ final cacheManager = Get .find <TokenOidcCacheManager >();
55
+
56
+ // assert
57
+ expect (cacheManager, isInstanceOf <TokenOidcCacheManager >());
58
+ });
59
+ });
60
+ }
0 commit comments