Files
suixinkan_uikit/suixinkanTests/APIErrorTests.swift
汉秋 699f1ba7c4 Add networking layer and wire up v9 login flow with unit tests.
Introduce APIClient/AuthAPI, complete login with multi-account selection, and polish the login card UI with shadow and keyboard dismiss.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 15:33:34 +08:00

30 lines
1.0 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// APIErrorTests.swift
// suixinkanTests
//
import XCTest
@testable import suixinkan
///
final class APIErrorTests: XCTestCase {
func testAuthenticationExpiredForUnauthorizedHTTPStatus() {
XCTAssertTrue(APIError.isAuthenticationExpired(APIError.httpStatus(401, "Unauthorized")))
XCTAssertTrue(APIError.isAuthenticationExpired(APIError.httpStatus(403, "Forbidden")))
}
func testAuthenticationExpiredForAndroidTokenInvalidCodes() {
for code in [180024, 100091, 100090, 100060] {
XCTAssertTrue(
APIError.isAuthenticationExpired(APIError.serverCode(code, "token 失效")),
"code \(code) 应识别为 token 失效"
)
}
}
func testNetworkErrorIsNotAuthenticationExpired() {
XCTAssertFalse(APIError.isAuthenticationExpired(APIError.networkFailed("请求超时,请稍后重试")))
XCTAssertFalse(APIError.isAuthenticationExpired(APIError.serverCode(100001, "密码错误")))
}
}