Skip to content

Commit 0696b71

Browse files
gnpricechrisbobbe
authored andcommitted
test [nfc]: Make addUserTopic async
This is the next step toward making handleEvent async.
1 parent 6469f23 commit 0696b71

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

test/model/message_list_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,9 @@ void main() async {
561561
await prepare(narrow: const AllMessagesNarrow());
562562
await store.addStreams([stream1, stream2]);
563563
await store.addSubscription(eg.subscription(stream1));
564-
store.addUserTopic(stream1, 'B', UserTopicVisibilityPolicy.muted);
564+
await store.addUserTopic(stream1, 'B', UserTopicVisibilityPolicy.muted);
565565
await store.addSubscription(eg.subscription(stream2, isMuted: true));
566-
store.addUserTopic(stream2, 'C', UserTopicVisibilityPolicy.unmuted);
566+
await store.addUserTopic(stream2, 'C', UserTopicVisibilityPolicy.unmuted);
567567

568568
// Check filtering on fetchInitial…
569569
await prepareMessages(foundOldest: false, messages: [
@@ -618,8 +618,8 @@ void main() async {
618618
await prepare(narrow: StreamNarrow(stream.streamId));
619619
await store.addStream(stream);
620620
await store.addSubscription(eg.subscription(stream, isMuted: true));
621-
store.addUserTopic(stream, 'A', UserTopicVisibilityPolicy.unmuted);
622-
store.addUserTopic(stream, 'C', UserTopicVisibilityPolicy.muted);
621+
await store.addUserTopic(stream, 'A', UserTopicVisibilityPolicy.unmuted);
622+
await store.addUserTopic(stream, 'C', UserTopicVisibilityPolicy.muted);
623623

624624
// Check filtering on fetchInitial…
625625
await prepareMessages(foundOldest: false, messages: [
@@ -662,7 +662,7 @@ void main() async {
662662
await prepare(narrow: TopicNarrow(stream.streamId, 'A'));
663663
await store.addStream(stream);
664664
await store.addSubscription(eg.subscription(stream, isMuted: true));
665-
store.addUserTopic(stream, 'A', UserTopicVisibilityPolicy.muted);
665+
await store.addUserTopic(stream, 'A', UserTopicVisibilityPolicy.muted);
666666

667667
// Check filtering on fetchInitial…
668668
await prepareMessages(foundOldest: false, messages: [

test/model/stream_test.dart

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,21 @@ void main() {
116116
.equals(UserTopicVisibilityPolicy.none);
117117
});
118118

119-
test('with nothing for topic', () {
120-
final store = eg.store()
121-
..addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.muted);
119+
test('with nothing for topic', () async {
120+
final store = eg.store();
121+
await store.addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.muted);
122122
check(store.topicVisibilityPolicy(stream1.streamId, 'topic'))
123123
.equals(UserTopicVisibilityPolicy.none);
124124
});
125125

126-
test('with topic present', () {
126+
test('with topic present', () async {
127127
final store = eg.store();
128128
for (final policy in [
129129
UserTopicVisibilityPolicy.muted,
130130
UserTopicVisibilityPolicy.unmuted,
131131
UserTopicVisibilityPolicy.followed,
132132
]) {
133-
store.addUserTopic(stream1, 'topic', policy);
133+
await store.addUserTopic(stream1, 'topic', policy);
134134
check(store.topicVisibilityPolicy(stream1.streamId, 'topic'))
135135
.equals(policy);
136136
}
@@ -165,7 +165,7 @@ void main() {
165165
final store = eg.store();
166166
await store.addStream(stream1);
167167
await store.addSubscription(eg.subscription(stream1));
168-
store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
168+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
169169
check(store.isTopicVisibleInStream(stream1.streamId, 'topic')).isFalse();
170170
check(store.isTopicVisible (stream1.streamId, 'topic')).isFalse();
171171
});
@@ -174,7 +174,7 @@ void main() {
174174
final store = eg.store();
175175
await store.addStream(stream1);
176176
await store.addSubscription(eg.subscription(stream1, isMuted: true));
177-
store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unmuted);
177+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unmuted);
178178
check(store.isTopicVisibleInStream(stream1.streamId, 'topic')).isTrue();
179179
check(store.isTopicVisible (stream1.streamId, 'topic')).isTrue();
180180
});
@@ -183,7 +183,7 @@ void main() {
183183
final store = eg.store();
184184
await store.addStream(stream1);
185185
await store.addSubscription(eg.subscription(stream1, isMuted: true));
186-
store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.followed);
186+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.followed);
187187
check(store.isTopicVisibleInStream(stream1.streamId, 'topic')).isTrue();
188188
check(store.isTopicVisible (stream1.streamId, 'topic')).isTrue();
189189
});
@@ -229,55 +229,55 @@ void main() {
229229
});
230230

231231
group('events', () {
232-
test('add with new stream', () {
233-
final store = eg.store()
234-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
232+
test('add with new stream', () async {
233+
final store = eg.store();
234+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
235235
compareTopicVisibility(store, [
236236
makeUserTopicItem(stream1, 'topic', UserTopicVisibilityPolicy.muted),
237237
]);
238238
});
239239

240-
test('add in existing stream', () {
241-
final store = eg.store()
242-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted)
243-
..addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted);
240+
test('add in existing stream', () async {
241+
final store = eg.store();
242+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
243+
await store.addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted);
244244
compareTopicVisibility(store, [
245245
makeUserTopicItem(stream1, 'topic', UserTopicVisibilityPolicy.muted),
246246
makeUserTopicItem(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted),
247247
]);
248248
});
249249

250-
test('update existing policy', () {
251-
final store = eg.store()
252-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted)
253-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unmuted);
250+
test('update existing policy', () async {
251+
final store = eg.store();
252+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
253+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unmuted);
254254
compareTopicVisibility(store, [
255255
makeUserTopicItem(stream1, 'topic', UserTopicVisibilityPolicy.unmuted),
256256
]);
257257
});
258258

259-
test('remove, with others in stream', () {
260-
final store = eg.store()
261-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted)
262-
..addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted)
263-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.none);
259+
test('remove, with others in stream', () async {
260+
final store = eg.store();
261+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
262+
await store.addUserTopic(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted);
263+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.none);
264264
compareTopicVisibility(store, [
265265
makeUserTopicItem(stream1, 'other topic', UserTopicVisibilityPolicy.unmuted),
266266
]);
267267
});
268268

269-
test('remove, as last in stream', () {
270-
final store = eg.store()
271-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted)
272-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.none);
269+
test('remove, as last in stream', () async {
270+
final store = eg.store();
271+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
272+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.none);
273273
compareTopicVisibility(store, [
274274
]);
275275
});
276276

277-
test('treat unknown enum value as removing', () {
278-
final store = eg.store()
279-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted)
280-
..addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unknown);
277+
test('treat unknown enum value as removing', () async {
278+
final store = eg.store();
279+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.muted);
280+
await store.addUserTopic(stream1, 'topic', UserTopicVisibilityPolicy.unknown);
281281
compareTopicVisibility(store, [
282282
]);
283283
});

test/model/test_store.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ extension PerAccountStoreTestExtension on PerAccountStore {
140140
handleEvent(SubscriptionAddEvent(id: 1, subscriptions: subscriptions));
141141
}
142142

143-
void addUserTopic(ZulipStream stream, String topic, UserTopicVisibilityPolicy visibilityPolicy) {
143+
Future<void> addUserTopic(ZulipStream stream, String topic, UserTopicVisibilityPolicy visibilityPolicy) async {
144144
handleEvent(UserTopicEvent(
145145
id: 1,
146146
streamId: stream.streamId,

test/model/unreads_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void main() {
161161
await streamStore.addSubscription(eg.subscription(stream1));
162162
await streamStore.addSubscription(eg.subscription(stream2));
163163
await streamStore.addSubscription(eg.subscription(stream3, isMuted: true));
164-
streamStore.addUserTopic(stream1, 'a', UserTopicVisibilityPolicy.muted);
164+
await streamStore.addUserTopic(stream1, 'a', UserTopicVisibilityPolicy.muted);
165165
fillWithMessages([
166166
eg.streamMessage(stream: stream1, topic: 'a', flags: []),
167167
eg.streamMessage(stream: stream1, topic: 'b', flags: []),
@@ -179,8 +179,8 @@ void main() {
179179
prepare();
180180
await streamStore.addStream(stream);
181181
await streamStore.addSubscription(eg.subscription(stream));
182-
streamStore.addUserTopic(stream, 'a', UserTopicVisibilityPolicy.unmuted);
183-
streamStore.addUserTopic(stream, 'c', UserTopicVisibilityPolicy.muted);
182+
await streamStore.addUserTopic(stream, 'a', UserTopicVisibilityPolicy.unmuted);
183+
await streamStore.addUserTopic(stream, 'c', UserTopicVisibilityPolicy.muted);
184184
fillWithMessages([
185185
eg.streamMessage(stream: stream, topic: 'a', flags: []),
186186
eg.streamMessage(stream: stream, topic: 'a', flags: []),

test/widgets/inbox_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ void main() {
199199
streams: [stream],
200200
subscriptions: [subscription],
201201
unreadMessages: [eg.streamMessage(stream: stream, topic: 'lunch')]);
202-
store.addUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.muted);
202+
await store.addUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.muted);
203203
await tester.pump();
204204
check(tester.widgetList(find.text('lunch'))).length.equals(0);
205205
});
@@ -221,7 +221,7 @@ void main() {
221221
streams: [stream],
222222
subscriptions: [subscription],
223223
unreadMessages: [eg.streamMessage(stream: stream, topic: 'lunch')]);
224-
store.addUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.unmuted);
224+
await store.addUserTopic(stream, 'lunch', UserTopicVisibilityPolicy.unmuted);
225225
await tester.pump();
226226
check(tester.widgetList(find.text('lunch'))).length.equals(1);
227227
});

0 commit comments

Comments
 (0)