Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
fluttertpc_get
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
aryan-more
2023-07-03 17:32:50 +0530
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c38547651e94ab62b3f05f5e83cbaaa0ffcb71ac
c3854765
1 parent
b677cc61
Added test case for findOrNull
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
18 deletions
test/instance/get_instance_test.dart
test/instance/get_instance_test.dart
View file @
c385476
...
...
@@ -55,12 +55,9 @@ void main() {
final
instance
=
Get
.
put
<
Controller
>(
Controller
(),
tag:
'one'
);
final
instance2
=
Get
.
put
<
Controller
>(
Controller
(),
tag:
'two'
);
expect
(
instance
==
instance2
,
false
);
expect
(
Get
.
find
<
Controller
>(
tag:
'one'
)
==
Get
.
find
<
Controller
>(
tag:
'two'
),
false
);
expect
(
Get
.
find
<
Controller
>(
tag:
'one'
)
==
Get
.
find
<
Controller
>(
tag:
'one'
),
true
);
expect
(
Get
.
find
<
Controller
>(
tag:
'two'
)
==
Get
.
find
<
Controller
>(
tag:
'two'
),
true
);
expect
(
Get
.
find
<
Controller
>(
tag:
'one'
)
==
Get
.
find
<
Controller
>(
tag:
'two'
),
false
);
expect
(
Get
.
find
<
Controller
>(
tag:
'one'
)
==
Get
.
find
<
Controller
>(
tag:
'one'
),
true
);
expect
(
Get
.
find
<
Controller
>(
tag:
'two'
)
==
Get
.
find
<
Controller
>(
tag:
'two'
),
true
);
Get
.
reset
();
});
...
...
@@ -68,12 +65,9 @@ void main() {
Get
.
lazyPut
<
Controller
>(()
=>
Controller
(),
tag:
'one'
);
Get
.
lazyPut
<
Controller
>(()
=>
Controller
(),
tag:
'two'
);
expect
(
Get
.
find
<
Controller
>(
tag:
'one'
)
==
Get
.
find
<
Controller
>(
tag:
'two'
),
false
);
expect
(
Get
.
find
<
Controller
>(
tag:
'one'
)
==
Get
.
find
<
Controller
>(
tag:
'one'
),
true
);
expect
(
Get
.
find
<
Controller
>(
tag:
'two'
)
==
Get
.
find
<
Controller
>(
tag:
'two'
),
true
);
expect
(
Get
.
find
<
Controller
>(
tag:
'one'
)
==
Get
.
find
<
Controller
>(
tag:
'two'
),
false
);
expect
(
Get
.
find
<
Controller
>(
tag:
'one'
)
==
Get
.
find
<
Controller
>(
tag:
'one'
),
true
);
expect
(
Get
.
find
<
Controller
>(
tag:
'two'
)
==
Get
.
find
<
Controller
>(
tag:
'two'
),
true
);
Get
.
reset
();
});
...
...
@@ -101,8 +95,7 @@ void main() {
expect
(
Get
.
find
<
Controller
>().
count
,
1
);
Get
.
delete
<
Controller
>();
expect
(
()
=>
Get
.
find
<
Controller
>(),
throwsA
(
const
m
.
TypeMatcher
<
String
>()));
expect
(()
=>
Get
.
find
<
Controller
>(),
throwsA
(
const
m
.
TypeMatcher
<
String
>()));
Get
.
reset
();
});
...
...
@@ -162,12 +155,10 @@ void main() {
test
(
'Get.delete test with disposable controller'
,
()
async
{
// Get.put(DisposableController());
expect
(
Get
.
delete
<
DisposableController
>(),
true
);
expect
(()
=>
Get
.
find
<
DisposableController
>(),
throwsA
(
const
m
.
TypeMatcher
<
String
>()));
expect
(()
=>
Get
.
find
<
DisposableController
>(),
throwsA
(
const
m
.
TypeMatcher
<
String
>()));
});
test
(
'Get.put test after delete with disposable controller and init check'
,
()
async
{
test
(
'Get.put test after delete with disposable controller and init check'
,
()
async
{
final
instance
=
Get
.
put
<
DisposableController
>(
DisposableController
());
expect
(
instance
,
Get
.
find
<
DisposableController
>());
expect
(
instance
.
initialized
,
true
);
...
...
@@ -253,6 +244,20 @@ void main() {
expect
((
Get
.
find
<
DisposableController
>()
as
Controller
).
count
,
0
);
});
});
group
(
'Get.findOrNull test'
,
()
{
tearDown
(
Get
.
reset
);
test
(
'checking results'
,
()
async
{
Get
.
put
<
int
>(
1
);
int
?
result
=
Get
.
findOrNull
<
int
>();
expect
(
result
,
1
);
Get
.
delete
<
int
>();
result
=
Get
.
findOrNull
<
int
>();
expect
(
result
,
null
);
});
});
}
class
PermanentService
extends
GetxService
{}
...
...
Please
register
or
login
to post a comment