aryan-more

Added test case for findOrNull

@@ -55,12 +55,9 @@ void main() { @@ -55,12 +55,9 @@ void main() {
55 final instance = Get.put<Controller>(Controller(), tag: 'one'); 55 final instance = Get.put<Controller>(Controller(), tag: 'one');
56 final instance2 = Get.put<Controller>(Controller(), tag: 'two'); 56 final instance2 = Get.put<Controller>(Controller(), tag: 'two');
57 expect(instance == instance2, false); 57 expect(instance == instance2, false);
58 - expect(Get.find<Controller>(tag: 'one') == Get.find<Controller>(tag: 'two'),  
59 - false);  
60 - expect(Get.find<Controller>(tag: 'one') == Get.find<Controller>(tag: 'one'),  
61 - true);  
62 - expect(Get.find<Controller>(tag: 'two') == Get.find<Controller>(tag: 'two'),  
63 - true); 58 + expect(Get.find<Controller>(tag: 'one') == Get.find<Controller>(tag: 'two'), false);
  59 + expect(Get.find<Controller>(tag: 'one') == Get.find<Controller>(tag: 'one'), true);
  60 + expect(Get.find<Controller>(tag: 'two') == Get.find<Controller>(tag: 'two'), true);
64 Get.reset(); 61 Get.reset();
65 }); 62 });
66 63
@@ -68,12 +65,9 @@ void main() { @@ -68,12 +65,9 @@ void main() {
68 Get.lazyPut<Controller>(() => Controller(), tag: 'one'); 65 Get.lazyPut<Controller>(() => Controller(), tag: 'one');
69 Get.lazyPut<Controller>(() => Controller(), tag: 'two'); 66 Get.lazyPut<Controller>(() => Controller(), tag: 'two');
70 67
71 - expect(Get.find<Controller>(tag: 'one') == Get.find<Controller>(tag: 'two'),  
72 - false);  
73 - expect(Get.find<Controller>(tag: 'one') == Get.find<Controller>(tag: 'one'),  
74 - true);  
75 - expect(Get.find<Controller>(tag: 'two') == Get.find<Controller>(tag: 'two'),  
76 - true); 68 + expect(Get.find<Controller>(tag: 'one') == Get.find<Controller>(tag: 'two'), false);
  69 + expect(Get.find<Controller>(tag: 'one') == Get.find<Controller>(tag: 'one'), true);
  70 + expect(Get.find<Controller>(tag: 'two') == Get.find<Controller>(tag: 'two'), true);
77 Get.reset(); 71 Get.reset();
78 }); 72 });
79 73
@@ -101,8 +95,7 @@ void main() { @@ -101,8 +95,7 @@ void main() {
101 95
102 expect(Get.find<Controller>().count, 1); 96 expect(Get.find<Controller>().count, 1);
103 Get.delete<Controller>(); 97 Get.delete<Controller>();
104 - expect(  
105 - () => Get.find<Controller>(), throwsA(const m.TypeMatcher<String>())); 98 + expect(() => Get.find<Controller>(), throwsA(const m.TypeMatcher<String>()));
106 Get.reset(); 99 Get.reset();
107 }); 100 });
108 101
@@ -162,12 +155,10 @@ void main() { @@ -162,12 +155,10 @@ void main() {
162 test('Get.delete test with disposable controller', () async { 155 test('Get.delete test with disposable controller', () async {
163 // Get.put(DisposableController()); 156 // Get.put(DisposableController());
164 expect(Get.delete<DisposableController>(), true); 157 expect(Get.delete<DisposableController>(), true);
165 - expect(() => Get.find<DisposableController>(),  
166 - throwsA(const m.TypeMatcher<String>())); 158 + expect(() => Get.find<DisposableController>(), throwsA(const m.TypeMatcher<String>()));
167 }); 159 });
168 160
169 - test('Get.put test after delete with disposable controller and init check',  
170 - () async { 161 + test('Get.put test after delete with disposable controller and init check', () async {
171 final instance = Get.put<DisposableController>(DisposableController()); 162 final instance = Get.put<DisposableController>(DisposableController());
172 expect(instance, Get.find<DisposableController>()); 163 expect(instance, Get.find<DisposableController>());
173 expect(instance.initialized, true); 164 expect(instance.initialized, true);
@@ -253,6 +244,20 @@ void main() { @@ -253,6 +244,20 @@ void main() {
253 expect((Get.find<DisposableController>() as Controller).count, 0); 244 expect((Get.find<DisposableController>() as Controller).count, 0);
254 }); 245 });
255 }); 246 });
  247 +
  248 + group('Get.findOrNull test', () {
  249 + tearDown(Get.reset);
  250 + test('checking results', () async {
  251 + Get.put<int>(1);
  252 + int? result = Get.findOrNull<int>();
  253 + expect(result, 1);
  254 +
  255 + Get.delete<int>();
  256 + result = Get.findOrNull<int>();
  257 + expect(result, null);
  258 +
  259 + });
  260 + });
256 } 261 }
257 262
258 class PermanentService extends GetxService {} 263 class PermanentService extends GetxService {}