Skip to content

Commit

Permalink
savepoint
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed Sep 19, 2024
1 parent 0b420c2 commit 0ab6c83
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ final class AutomaticSocketConnectionHandlerTests: XCTestCase {

// Assign onConnect closure to fulfill the expectation and set isConnected
webSocketSession.onConnect = {
self.webSocketSession.isConnected = true
expectation.fulfill()
}

// Simulate network connection becoming connected
networkMonitor.networkConnectionStatusPublisherSubject.send(.connected)

wait(for: [expectation], timeout: 0.1)
XCTAssertTrue(webSocketSession.isConnected)
wait(for: [expectation], timeout: 10)
}

func testHandleConnectThrows() {
Expand Down Expand Up @@ -212,7 +210,6 @@ final class AutomaticSocketConnectionHandlerTests: XCTestCase {
for _ in 0..<sut.maxImmediateAttempts {
print("Simulating disconnection")
socketStatusProviderMock.simulateConnectionStatus(.disconnected)
webSocketSession.isConnected = false

// Wait to allow the handler to process each disconnection
try? await Task.sleep(nanoseconds: 500_000_000) // 200ms
Expand All @@ -222,7 +219,7 @@ final class AutomaticSocketConnectionHandlerTests: XCTestCase {
socketStatusProviderMock.simulateConnectionStatus(.disconnected)

// Allow time for the reconnection logic to switch to periodic
try? await Task.sleep(nanoseconds: 500_000_000) // 500ms
try? await Task.sleep(nanoseconds: 1_000_000_000) // 500ms

// Verify that reconnectionAttempts is set to maxImmediateAttempts and timer is started
sut.syncQueue.sync {
Expand Down

0 comments on commit 0ab6c83

Please sign in to comment.