import ForgejoKit
import Foundation
import Testing
@testable import Forji

struct ContentViewTests {

    // MARK: - shouldLogout

    @Test func logsOutOnConfirmedTokenExpired() {
        #expect(ContentView.shouldLogout(after: SessionRestoreError.tokenExpired))
    }

    @Test func logsOutOnConfirmedPermissionDenied() {
        #expect(ContentView.shouldLogout(after: SessionRestoreError.tokenPermissionDenied))
    }

    @Test func doesNotLogOutOnNetworkUnavailable() {
        #expect(!ContentView.shouldLogout(after: SessionRestoreError.networkUnavailable))
    }

    @Test func doesNotLogOutOnServerUnavailable() {
        #expect(!ContentView.shouldLogout(after: SessionRestoreError.serverUnavailable))
    }

    @Test func doesNotLogOutOnRawURLError() {
        // Errors that never made it through SessionRestoreError classification
        // must not be treated as a confirmed credential rejection.
        #expect(!ContentView.shouldLogout(after: URLError(.notConnectedToInternet)))
    }
}
