Skip to content

Commit 59e78c8

Browse files
committed
store test: Add test for GlobalStoreWidget.of
1 parent 70824b4 commit 59e78c8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/widgets/store_test.dart

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extension MyWidgetWithMixinStateChecks on Subject<MyWidgetWithMixinState> {
5757
void main() {
5858
TestZulipBinding.ensureInitialized();
5959

60-
testWidgets('GlobalStoreWidget', (tester) async {
60+
testWidgets('GlobalStoreWidget loads data while showing placeholder', (tester) async {
6161
addTearDown(testBinding.reset);
6262

6363
GlobalStore? globalStore;
@@ -83,6 +83,25 @@ void main() {
8383
.equals((accountId: eg.selfAccount.id, account: eg.selfAccount));
8484
});
8585

86+
testWidgets('GlobalStoreWidget.of updates dependents', (tester) async {
87+
addTearDown(testBinding.reset);
88+
89+
List<int>? accountIds;
90+
await tester.pumpWidget(
91+
Directionality(textDirection: TextDirection.ltr,
92+
child: GlobalStoreWidget(
93+
child: Builder(builder: (context) {
94+
accountIds = GlobalStoreWidget.of(context).accountIds.toList();
95+
return SizedBox.shrink();
96+
}))));
97+
await tester.pump();
98+
check(accountIds).isNotNull().isEmpty();
99+
100+
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
101+
await tester.pump();
102+
check(accountIds).isNotNull().deepEquals([eg.selfAccount.id]);
103+
});
104+
86105
testWidgets('PerAccountStoreWidget basic', (tester) async {
87106
await testBinding.globalStore.add(eg.selfAccount, eg.initialSnapshot());
88107
addTearDown(testBinding.reset);

0 commit comments

Comments
 (0)