This commit is contained in:
Salvatore Giordano
2022-04-14 11:32:32 +02:00
parent a2f1981a2f
commit da4fd16af7
@@ -59,7 +59,10 @@ void main() {
});
test('`connect` successfully with the provided user', () async {
final user = OwnUser(id: 'test-user');
final user = OwnUser(
id: 'test-user',
name: 'test',
);
const connectionId = 'test-connection-id';
// Sends connect event to web-socket stream
final timer = Timer(const Duration(milliseconds: 300), () {
@@ -90,6 +93,44 @@ void main() {
addTearDown(timer.cancel);
});
test('`connect` successfully without user details', () async {
final user = OwnUser(
id: 'test-user',
name: 'test',
);
const connectionId = 'test-connection-id';
// Sends connect event to web-socket stream
final timer = Timer(const Duration(milliseconds: 300), () {
final event = Event(
type: EventType.healthCheck,
connectionId: connectionId,
me: user,
);
webSocketSink.add(json.encode(event));
});
expectLater(
webSocket.connectionStatusStream,
emitsInOrder([
ConnectionStatus.disconnected,
ConnectionStatus.connecting,
ConnectionStatus.connected,
]),
);
final event = await webSocket.connect(
user,
includeUserDetails: true,
);
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);