//
//  RealNameAuthViewModelTests.swift
//  suixinkanTests
//

import XCTest
@testable import suixinkan

/// 实名认证 ViewModel 测试。
final class RealNameAuthViewModelTests: XCTestCase {
    func testValidationRequiresSmsCodeWhenNotVerified() {
        let viewModel = RealNameAuthViewModel()
        viewModel.updateRealName("张三")
        viewModel.updateIdCardNo("11010519491231002X")

        XCTAssertEqual(viewModel.validationMessage, "请输入短信验证码")
    }

    func testIsValidMainlandIDCardNumberChecksChecksum() {
        XCTAssertTrue(RealNameAuthViewModel.isValidMainlandIDCardNumber("11010519491231002X"))
        XCTAssertFalse(RealNameAuthViewModel.isValidMainlandIDCardNumber("123"))
    }

    func testNormalizedIDCardNumberUppercasesSuffix() {
        XCTAssertEqual(
            RealNameAuthViewModel.normalizedIDCardNumber("11010519491231002x"),
            "11010519491231002X"
        )
    }
}
