Implement profile tab with Android-aligned flows and OSS upload.
Add personal info page, account switch, real-name auth, withdrawal settings, session cache extensions, AlibabaCloudOSS SPM, and unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
65
suixinkanTests/ProfileModelsTests.swift
Normal file
65
suixinkanTests/ProfileModelsTests.swift
Normal file
@ -0,0 +1,65 @@
|
||||
//
|
||||
// ProfileModelsTests.swift
|
||||
// suixinkanTests
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import suixinkan
|
||||
|
||||
/// Profile 模型解码测试。
|
||||
final class ProfileModelsTests: XCTestCase {
|
||||
func testUserInfoResponseDecodesSnakeCaseFields() throws {
|
||||
let json = """
|
||||
{
|
||||
"avatar": "https://cdn.example.com/a.jpg",
|
||||
"real_name": "张三",
|
||||
"phone": "13800138000",
|
||||
"nickname": "小张",
|
||||
"role_name": "摄影师",
|
||||
"status": 1,
|
||||
"status_name": "正常"
|
||||
}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
let info = try JSONDecoder().decode(UserInfoResponse.self, from: json)
|
||||
|
||||
XCTAssertEqual(info.realName, "张三")
|
||||
XCTAssertEqual(info.nickname, "小张")
|
||||
XCTAssertEqual(info.roleName, "摄影师")
|
||||
XCTAssertEqual(info.statusName, "正常")
|
||||
}
|
||||
|
||||
func testBankCardInfoDecodesAuditStatusAsString() throws {
|
||||
let json = """
|
||||
{
|
||||
"real_name": "张三",
|
||||
"bank_name": "中国银行",
|
||||
"branch_name": "南京支行",
|
||||
"card_number": "6222021234567890",
|
||||
"audit_status": "2",
|
||||
"audit_status_label": "审核通过",
|
||||
"reject_reason": ""
|
||||
}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
let info = try JSONDecoder().decode(BankCardInfo.self, from: json)
|
||||
|
||||
XCTAssertEqual(info.auditStatus, 2)
|
||||
XCTAssertEqual(info.bankName, "中国银行")
|
||||
}
|
||||
|
||||
func testRealNameInfoVerifiedWhenAuditStatusIsTwo() throws {
|
||||
let json = """
|
||||
{
|
||||
"real_name": "张三",
|
||||
"id_card_no": "320102199001011234",
|
||||
"audit_status": 2,
|
||||
"is_long_valid": 1
|
||||
}
|
||||
""".data(using: .utf8)!
|
||||
|
||||
let info = try JSONDecoder().decode(RealNameInfo.self, from: json)
|
||||
|
||||
XCTAssertTrue(info.verified)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user