fix(llc): fix connecting while connecting and disconneting (#1237)

* fix(llc): fix connecting while connecting and disconneting

* chore(llc): update changelog

* chore(llc): add test

* chore(llc): improve test

* fix(llc): _resetRequestFlags regardless of the connection status
This commit is contained in:
Salvatore Giordano
2022-07-05 12:08:08 +02:00
committed by GitHub
parent d2883c87f0
commit a37bf2bde4
3 changed files with 44 additions and 0 deletions
@@ -131,6 +131,40 @@ void main() {
addTearDown(timer.cancel);
});
test('`connect`, `disconnect` and `connect` again without waiting', () async {
final user = OwnUser(
id: 'test-user',
name: 'test',
);
const connectionId = 'test-connection-id';
// Sends connect event to web-socket stream
final timer = Timer.periodic(const Duration(milliseconds: 300), (_) {
final event = Event(
type: EventType.healthCheck,
connectionId: connectionId,
me: user,
);
webSocketSink.add(json.encode(event));
});
await webSocket.connect(
user,
);
webSocket
..disconnect()
..connect(user)
..disconnect();
final event = await webSocket.connect(user);
expect(event.type, EventType.healthCheck);
expect(event.connectionId, connectionId);
expect(event.me, isNotNull);
expect(event.me!.id, user.id);
addTearDown(timer.cancel);
});
test('`connect` should throw if already in connection attempt', () async {
final user = OwnUser(id: 'test-user');
webSocket.connect(user);