Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed Sep 19, 2024
1 parent 1558d22 commit a71a51d
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class AutomaticSocketConnectionHandlerTests: XCTestCase {
appStateObserver = AppStateObserverMock()

let defaults = RuntimeKeyValueStorage()
let logger = ConsoleLoggerMock()
let logger = ConsoleLogger(prefix: "", loggingLevel: .debug)
let keychainStorageMock = DispatcherKeychainStorageMock()

backgroundTaskRegistrar = BackgroundTaskRegistrarMock()
Expand Down Expand Up @@ -191,8 +191,7 @@ final class AutomaticSocketConnectionHandlerTests: XCTestCase {

func testReconnectsOnEnterForegroundWhenSubscribed() async {
subscriptionsTracker.isSubscribedReturnValue = true // Simulate that there are active subscriptions
webSocketSession.disconnect()
XCTAssertFalse(webSocketSession.isConnected)
webSocketSession.isConnected = false

let expectation = XCTestExpectation(description: "WebSocket should reconnect when entering foreground and subscriptions exist")

Expand All @@ -204,14 +203,14 @@ final class AutomaticSocketConnectionHandlerTests: XCTestCase {
// Simulate entering foreground
appStateObserver.onWillEnterForeground?()

await fulfillment(of: [expectation], timeout: 1.0)
await fulfillment(of: [expectation], timeout: 5.0)

XCTAssertTrue(webSocketSession.isConnected)
}

func testSwitchesToPeriodicReconnectionAfterMaxImmediateAttempts() async {
subscriptionsTracker.isSubscribedReturnValue = true // Ensure subscriptions exist to allow reconnection
sut.periodicReconnectionInterval = 0.1 // Set shorter interval for testing
sut.periodicReconnectionInterval = 3 // Set shorter interval for testing
sut.connect() // Start connection process

// Simulate immediate reconnection attempts
Expand Down

0 comments on commit a71a51d

Please sign in to comment.