Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/collaboration/awareness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ describe('collaboration awareness presentation', () => {
expect(collaborationConnectionLabel(status)).toBe(label);
});

it('rejects a runtime connection status outside the public states', () => {
expect(() => collaborationConnectionLabel('failed' as never)).toThrowError(
new RangeError(
'Collaboration connection status must be connecting, connected, disconnected, or offline.',
),
);
});

it('renders a text-only high-contrast cursor for valid remote data', () => {
const cursor = renderCollaborationCursor({
name: 'Remote Alice',
Expand Down
6 changes: 5 additions & 1 deletion src/collaboration/awareness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ export function collaborationConnectionLabel(
status: CollaborationConnectionStatus | undefined,
): string {
switch (status) {
case undefined:
return 'Collaboration ready';
case 'connecting':
return 'Connecting';
case 'connected':
Expand All @@ -224,7 +226,9 @@ export function collaborationConnectionLabel(
case 'offline':
return 'Offline';
default:
return 'Collaboration ready';
throw new RangeError(
'Collaboration connection status must be connecting, connected, disconnected, or offline.',
);
}
}

Expand Down
Loading