Skip to content

Commit 2e9cf8d

Browse files
committed
chore(api): auto reconnect is off and the state machine gets shutdown
1 parent 16c6702 commit 2e9cf8d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

packages/api/amplify_api_dart/test/web_socket/web_socket_bloc_test.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,48 @@ void main() {
639639

640640
await bloc.done.future;
641641
});
642+
643+
test('a process unpauses with autoReconnect disabled', () async {
644+
final blocReady = Completer<void>();
645+
final subscribeEvent = SubscribeEvent(
646+
subscriptionRequest,
647+
blocReady.complete,
648+
);
649+
final bloc = getWebSocketBloc();
650+
651+
expect(
652+
bloc.stream,
653+
emitsInOrder(
654+
[
655+
isA<DisconnectedState>(),
656+
isA<ConnectingState>(),
657+
isA<ConnectedState>(),
658+
isA<FailureState>(),
659+
isA<PendingDisconnect>(),
660+
isA<DisconnectedState>(),
661+
],
662+
),
663+
);
664+
665+
// ignore: invalid_use_of_internal_member
666+
WebSocketOptions.autoReconnect = false;
667+
668+
bloc.subscribe(subscribeEvent).listen(
669+
null,
670+
onError: expectAsync1((event) {
671+
expect(
672+
event,
673+
isA<ApiException>(),
674+
);
675+
}),
676+
);
677+
678+
await blocReady.future;
679+
680+
mockProcessLifeCycleController
681+
..add(ProcessStatus.paused)
682+
..add(ProcessStatus.resumed);
683+
});
642684
});
643685
});
644686
}

0 commit comments

Comments
 (0)