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
Ryan
2020-05-21 22:08:54 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d73e804c395699d372dd16e4df22cf83ceed8cae
d73e804c
1 parent
0468fb3c
feat: add tests for rx & get_state
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
0 deletions
test/get_rxstate_test.dart
test/get_state_test.dart
test/get_rxstate_test.dart
0 → 100644
View file @
d73e804
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:get/get.dart'
;
void
main
(
)
{
testWidgets
(
"GetController smoke test"
,
(
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
GetX
<
Controller
>(
init:
Controller
(),
builder:
(
controller
)
{
return
Column
(
children:
[
Text
(
'Count:
${controller.counter.value}
'
,
),
Text
(
'Double:
${controller.doubleNum.value}
'
,
),
Text
(
'String:
${controller.string.value}
'
,
),
Text
(
'List:
${controller.list.length}
'
,
),
Text
(
'Bool:
${controller.boolean.value}
'
,
),
Text
(
'Map:
${controller.map.value.length}
'
,
),
FlatButton
(
child:
Text
(
"increment"
),
onPressed:
()
=>
controller
.
increment
(),
)
],
);
},
),
),
);
expect
(
find
.
text
(
"Count: 0"
),
findsOneWidget
);
expect
(
find
.
text
(
"Double: 0.0"
),
findsOneWidget
);
expect
(
find
.
text
(
"String: string"
),
findsOneWidget
);
expect
(
find
.
text
(
"Bool: true"
),
findsOneWidget
);
expect
(
find
.
text
(
"List: 0"
),
findsOneWidget
);
expect
(
find
.
text
(
"Map: 0"
),
findsOneWidget
);
Controller
.
to
.
increment
();
await
tester
.
pump
();
expect
(
find
.
text
(
"Count: 1"
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'increment'
));
await
tester
.
pump
();
expect
(
find
.
text
(
"Count: 2"
),
findsOneWidget
);
});
}
class
Controller
extends
RxController
{
static
Controller
get
to
=>
Get
.
find
();
var
counter
=
0
.
obs
;
var
doubleNum
=
0.0
.
obs
;
var
string
=
"string"
.
obs
;
var
list
=
[].
obs
;
var
map
=
{}.
obs
;
var
boolean
=
true
.
obs
;
void
increment
()
{
counter
.
value
++;
}
}
...
...
test/get_state_test.dart
0 → 100644
View file @
d73e804
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:get/get.dart'
;
void
main
(
)
{
testWidgets
(
"GetController smoke test"
,
(
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
GetBuilder
<
Controller
>(
init:
Controller
(),
builder:
(
controller
)
=>
Column
(
children:
[
Text
(
'
${controller.counter}
'
,
),
FlatButton
(
child:
Text
(
"increment"
),
onPressed:
()
=>
controller
.
increment
(),
)
],
),
),
),
);
expect
(
find
.
text
(
"0"
),
findsOneWidget
);
Controller
.
to
.
increment
();
await
tester
.
pump
();
expect
(
find
.
text
(
"1"
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'increment'
));
await
tester
.
pump
();
expect
(
find
.
text
(
"2"
),
findsOneWidget
);
});
}
class
Controller
extends
GetController
{
static
Controller
get
to
=>
Get
.
find
();
int
counter
=
0
;
void
increment
()
{
counter
++;
update
(
this
);
}
}
...
...
Please
register
or
login
to post a comment