@@ -61,6 +61,7 @@ void main() {
61
61
when (mockPhoenixSocketOptions.getParams ())
62
62
.thenAnswer ((_) => optionsCompleter.future);
63
63
when (mockPhoenixSocketOptions.heartbeat).thenReturn (Duration (days: 1 ));
64
+ when (mockPhoenixSocketOptions.reconnectDelays).thenReturn ([Duration .zero]);
64
65
65
66
final sentRefs = < String > [];
66
67
when (mockPhoenixSocketOptions.serializer).thenReturn (MessageSerializer (
@@ -79,10 +80,11 @@ void main() {
79
80
WebSocketChannel stubWebSocketChannelFactory (Uri uri) {
80
81
++ factoryCalls;
81
82
final mockWebSocketChannel = MockWebSocketChannel ();
83
+ final mockWebSocketSink = MockWebSocketSink ();
82
84
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 );
86
88
return mockWebSocketChannel;
87
89
}
88
90
@@ -103,6 +105,7 @@ void main() {
103
105
104
106
optionsCompleter.complete ({'token' : 'fakeUserToken' });
105
107
108
+ await Future .delayed (Duration .zero);
106
109
await Future .delayed (Duration .zero);
107
110
108
111
for (final ref in sentRefs) {
@@ -135,6 +138,8 @@ void main() {
135
138
(async ) {
136
139
phoenixSocket.connect ();
137
140
141
+ async .elapse (Duration .zero);
142
+
138
143
verify (mockPhoenixSocketOptions.getParams ()).called (1 );
139
144
expect (phoenixSocket.isConnected, isFalse);
140
145
0 commit comments