Skip to content

Commit

Permalink
added test for obs with nullable value
Browse files Browse the repository at this point in the history
  • Loading branch information
wheeOs committed Sep 12, 2024
1 parent f7dcc98 commit 45fe11b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/state_manager/get_rxstate_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ void main() {
Text(
'Map: ${controller.map.length}',
),
Text(
'Nullable: ${controller.nullableNum.value}',
),
TextButton(
child: const Text("increment"),
onPressed: () => controller.increment(),
Expand All @@ -56,12 +59,14 @@ void main() {
expect(find.text("Bool: true"), findsOneWidget);
expect(find.text("List: 0"), findsOneWidget);
expect(find.text("Map: 0"), findsOneWidget);
expect(find.text("Nullable: null"), findsOneWidget);

Controller.to.increment();

await tester.pump();

expect(find.text("Count: 1"), findsOneWidget);
expect(find.text("Nullable: 0"), findsOneWidget);

await tester.tap(find.text('increment'));

Expand All @@ -86,12 +91,14 @@ class Controller extends GetxController {

RxInt counter = 0.obs;
RxDouble doubleNum = 0.0.obs;
final nullableNum = (null as int?).obs;
RxString string = "string".obs;
RxList list = [].obs;
RxMap map = {}.obs;
RxBool boolean = true.obs;

void increment() {
counter.value++;
nullableNum.value ??= 0;
}
}

0 comments on commit 45fe11b

Please sign in to comment.