feat: 更新项目配置和功能模块
- 修改Package.swift以支持iOS 15和macOS 12。 - 更新swift-tca-architecture-guidelines.mdc中的alwaysApply设置为false。 - 注释掉AppDelegate中的NIMSDK导入,移除不再使用的NIMConfigurationManager和NIMSessionManager文件。 - 添加新的API相关文件,包括EMailLoginFeature、IDLoginFeature和相关视图,增强登录功能。 - 更新APIConstants和APIEndpoints以反映新的API路径。 - 添加本地化支持文件,包含英文和中文简体的本地化字符串。 - 新增字体管理和安全工具类,支持AES和DES加密。 - 更新Xcode项目配置,调整版本号和启动画面设置。
This commit is contained in:
@@ -33,36 +33,44 @@ final class yanaAPITests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testClientInit_Success() {
|
||||
let expectation = self.expectation(description: "clientInit success")
|
||||
API.clientInit { result in
|
||||
switch result {
|
||||
case .success(let data):
|
||||
XCTAssertNotNil(data)
|
||||
// 可根据实际返回内容进一步断言
|
||||
case .failure(let error):
|
||||
XCTFail("Expected success, got error: \(error)")
|
||||
}
|
||||
expectation.fulfill()
|
||||
}
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
func testIDLoginRequest_Creation() {
|
||||
// 测试ID登录请求的创建
|
||||
let userID = "399113"
|
||||
let password = "a123456"
|
||||
|
||||
let request = LoginHelper.createIDLoginRequest(userID: userID, password: password)
|
||||
XCTAssertNotNil(request, "登录请求应该创建成功")
|
||||
XCTAssertEqual(request?.endpoint, "/oauth/token", "端点应该正确")
|
||||
XCTAssertEqual(request?.method, .POST, "请求方法应该是POST")
|
||||
}
|
||||
|
||||
func testClientInit_Failure() {
|
||||
// 可通过mock或断网等方式测试失败场景
|
||||
// 这里只做结构示例
|
||||
let expectation = self.expectation(description: "clientInit failure")
|
||||
// 假设API支持注入baseURL或mock
|
||||
API.clientInit { result in
|
||||
switch result {
|
||||
case .success(_):
|
||||
// 若期望失败则此处应fail
|
||||
XCTFail("Expected failure, got success")
|
||||
case .failure(let error):
|
||||
XCTAssertNotNil(error)
|
||||
}
|
||||
expectation.fulfill()
|
||||
}
|
||||
waitForExpectations(timeout: 5, handler: nil)
|
||||
|
||||
func testIDLoginResponse_Success() {
|
||||
// 测试登录响应的成功解析
|
||||
let successResponse = IDLoginResponse(
|
||||
status: "success",
|
||||
message: "登录成功",
|
||||
code: 200,
|
||||
data: IDLoginData(
|
||||
accessToken: "test_token",
|
||||
refreshToken: "refresh_token",
|
||||
tokenType: "Bearer",
|
||||
expiresIn: 3600,
|
||||
scope: "read write",
|
||||
userInfo: UserInfo(
|
||||
userId: "123",
|
||||
username: "testuser",
|
||||
nickname: "Test User",
|
||||
avatar: nil,
|
||||
email: "test@example.com",
|
||||
phone: "399113",
|
||||
status: "active",
|
||||
createTime: "2024-01-01",
|
||||
updateTime: "2024-01-01"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
XCTAssertTrue(successResponse.isSuccess, "响应应该标记为成功")
|
||||
XCTAssertEqual(successResponse.data?.accessToken, "test_token", "访问令牌应该正确")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user