Skip to content

Commit be87621

Browse files
committed
Fixing some tests
1 parent 758bac5 commit be87621

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

test/socket_test.dart

+8-3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void main() {
6161
when(mockPhoenixSocketOptions.getParams())
6262
.thenAnswer((_) => optionsCompleter.future);
6363
when(mockPhoenixSocketOptions.heartbeat).thenReturn(Duration(days: 1));
64+
when(mockPhoenixSocketOptions.reconnectDelays).thenReturn([Duration.zero]);
6465

6566
final sentRefs = <String>[];
6667
when(mockPhoenixSocketOptions.serializer).thenReturn(MessageSerializer(
@@ -79,10 +80,11 @@ void main() {
7980
WebSocketChannel stubWebSocketChannelFactory(Uri uri) {
8081
++factoryCalls;
8182
final mockWebSocketChannel = MockWebSocketChannel();
83+
final mockWebSocketSink = MockWebSocketSink();
8284
when(mockWebSocketChannel.stream).thenAnswer((_) => NeverStream());
83-
when(mockWebSocketChannel.ready)
84-
.thenAnswer((_) => Future.sync(() => null));
85-
when(mockWebSocketChannel.sink).thenReturn(MockWebSocketSink());
85+
when(mockWebSocketChannel.ready).thenAnswer((_) => Future.value());
86+
when(mockWebSocketChannel.sink).thenReturn(mockWebSocketSink);
87+
when(mockWebSocketSink.done).thenAnswer((_) => Completer<void>().future);
8688
return mockWebSocketChannel;
8789
}
8890

@@ -103,6 +105,7 @@ void main() {
103105

104106
optionsCompleter.complete({'token': 'fakeUserToken'});
105107

108+
await Future.delayed(Duration.zero);
106109
await Future.delayed(Duration.zero);
107110

108111
for (final ref in sentRefs) {
@@ -135,6 +138,8 @@ void main() {
135138
(async) {
136139
phoenixSocket.connect();
137140

141+
async.elapse(Duration.zero);
142+
138143
verify(mockPhoenixSocketOptions.getParams()).called(1);
139144
expect(phoenixSocket.isConnected, isFalse);
140145

0 commit comments

Comments
 (0)