@@ -4,99 +4,6 @@ import Testing
44
55@MainActor
66struct DefaultConnectionTests {
7- // MARK: - CHA-CS1: Connection Status Values
8-
9- // @spec CHA-CS1a
10- @Test
11- func initializedStatusIsDefaultWhenRealtimeClientFirstInitialized( ) async throws {
12- // Given: A realtime client with autoConnect = false
13- let options = ARTClientOptions ( key: " fake:key " )
14- options. autoConnect = false
15- let realtime = ARTRealtime ( options: options)
16- let client = ChatClient ( realtime: realtime, clientOptions: nil )
17-
18- // When: The connection status is checked
19- let status = client. connection. status
20-
21- // Then: Status should be INITIALIZED
22- #expect( status == . initialized)
23- }
24-
25- // @spec CHA-CS1b
26- @Test
27- func connectingStatusWhenClientIsConnecting( ) async throws {
28- // Given: A connection in CONNECTING state
29- let mockConnection = MockConnection ( state: . connecting)
30- let mockRealtime = MockRealtime ( connection: mockConnection)
31- let connection = DefaultConnection ( realtime: mockRealtime)
32-
33- // When: The connection status is checked
34- let status = connection. status
35-
36- // Then: Status should be CONNECTING
37- #expect( status == . connecting)
38- }
39-
40- // @spec CHA-CS1c
41- @Test
42- func connectedStatusWhenClientConnected( ) async throws {
43- // Given: A connection in CONNECTED state
44- let mockConnection = MockConnection ( state: . connected)
45- let mockRealtime = MockRealtime ( connection: mockConnection)
46- let connection = DefaultConnection ( realtime: mockRealtime)
47-
48- // When: The connection status is checked
49- let status = connection. status
50-
51- // Then: Status should be CONNECTED
52- #expect( status == . connected)
53- }
54-
55- // @spec CHA-CS1d
56- @Test
57- func disconnectedStatusWhenClientNotConnected( ) async throws {
58- // Given: A connection in DISCONNECTED state
59- let mockConnection = MockConnection ( state: . disconnected)
60- let mockRealtime = MockRealtime ( connection: mockConnection)
61- let connection = DefaultConnection ( realtime: mockRealtime)
62-
63- // When: The connection status is checked
64- let status = connection. status
65-
66- // Then: Status should be DISCONNECTED
67- #expect( status == . disconnected)
68- }
69-
70- // @spec CHA-CS1e
71- @Test
72- func suspendedStatusWhenClientInExtendedDisconnection( ) async throws {
73- // Given: A connection in SUSPENDED state
74- let mockConnection = MockConnection ( state: . suspended)
75- let mockRealtime = MockRealtime ( connection: mockConnection)
76- let connection = DefaultConnection ( realtime: mockRealtime)
77-
78- // When: The connection status is checked
79- let status = connection. status
80-
81- // Then: Status should be SUSPENDED
82- #expect( status == . suspended)
83- }
84-
85- // @spec CHA-CS1f
86- @Test
87- func failedStatusWhenClientDisconnectedPermanently( ) async throws {
88- // Given: A connection in FAILED state
89- let mockConnection = MockConnection ( state: . failed)
90- let mockRealtime = MockRealtime ( connection: mockConnection)
91- let connection = DefaultConnection ( realtime: mockRealtime)
92-
93- // When: The connection status is checked
94- let status = connection. status
95-
96- // Then: Status should be FAILED
97- #expect( status == . failed)
98- }
99-
1007 // MARK: - CHA-CS2: Exposing Connection Status and Error
1018
1029 // @spec CHA-CS2a
0 commit comments