Skip to content

Commit b4a61d8

Browse files
committed
typing test [nfc]: Make check typing request helper more flexible
The `connection.takeRequests` call is not helpful when there are some unrelated requests that do not need to be checked. Signed-off-by: Zixuan James Li <[email protected]>
1 parent bd68c26 commit b4a61d8

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/model/typing_status_test.dart

+7-7
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ void main() {
229229
late TopicNarrow narrow;
230230

231231
void checkSetTypingStatusRequests(
232-
FakeApiConnection connection,
233-
List<(TypingOp, SendableNarrow)> requests,
232+
List<http.BaseRequest> requests,
233+
List<(TypingOp, SendableNarrow)> expected,
234234
) {
235235
Condition<Object?> conditionTypingRequest(Map<String, String> expected) {
236236
return (Subject<Object?> it) => it.isA<http.Request>()
@@ -239,8 +239,8 @@ void main() {
239239
..bodyFields.deepEquals(expected);
240240
}
241241

242-
check(connection.takeRequests()).deepEquals([
243-
for (final (op, narrow) in requests)
242+
check(requests).deepEquals([
243+
for (final (op, narrow) in expected)
244244
switch (narrow) {
245245
TopicNarrow() => conditionTypingRequest({
246246
'type': 'channel',
@@ -256,7 +256,7 @@ void main() {
256256
}
257257

258258
void checkTypingRequest(TypingOp op, SendableNarrow narrow) =>
259-
checkSetTypingStatusRequests(connection, [(op, narrow)]);
259+
checkSetTypingStatusRequests(connection.takeRequests(), [(op, narrow)]);
260260

261261
Future<void> prepare() async {
262262
addTearDown(testBinding.reset);
@@ -421,7 +421,7 @@ void main() {
421421
connection.prepare(json: {});
422422
connection.prepare(json: {});
423423
model.keystroke(dmNarrow);
424-
checkSetTypingStatusRequests(connection,
424+
checkSetTypingStatusRequests(connection.takeRequests(),
425425
[(TypingOp.stop, topicNarrow), (TypingOp.start, dmNarrow)]);
426426

427427
async.elapse(Duration.zero);
@@ -466,7 +466,7 @@ void main() {
466466
connection.prepare(json: {});
467467
connection.prepare(json: {});
468468
model.keystroke(dmNarrow);
469-
checkSetTypingStatusRequests(connection,
469+
checkSetTypingStatusRequests(connection.takeRequests(),
470470
[(TypingOp.stop, topicNarrow), (TypingOp.start, dmNarrow)]);
471471

472472
while (async.elapsed <= model.typingStartedWaitPeriod) {

0 commit comments

Comments
 (0)