Files
suixinkan_ios_uikit/suixinkan_iosTests/MainScanPlusButtonTests.swift
汉秋 a1c031c9b7 Integrate CYLTabBar center scan button and unify UIKit navigation.
Add CYLTabBarController with a global scan entry, promote MainTabBarController to the window root after login, replace RouterPath-based navigation with AppNavigator, and fix Profile diffable cell reconfiguration crashes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-26 16:36:18 +08:00

59 lines
2.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.

//
// MainScanPlusButtonTests.swift
// suixinkanTests
//
import XCTest
@testable import suixinkan_ios
/// TabBar CYL PlusButton
@MainActor
final class MainScanPlusButtonTests: XCTestCase {
/// Tab
func testIndexOfPlusButtonInTabBarIsBetweenOrdersAndStatistics() {
XCTAssertEqual(MainScanPlusButton.indexOfPlusButtonInTabBar(), 2)
}
/// accessibility
func testPlusButtonAccessibilityIdentifier() {
guard let button = MainScanPlusButton.plusButton() as? UIButton else {
XCTFail("plusButton 应返回 UIButton 实例")
return
}
XCTAssertEqual(button.accessibilityIdentifier, "main.scan")
XCTAssertEqual(button.accessibilityLabel, "扫码核销")
}
/// Tab CYL Tab
func testMainTabBarControllerLoadsWithMatchingCYLAttributes() {
let services = AppServices(apiClient: APIClient(session: MainTabRecordingURLSession()))
let controller = MainTabBarController(services: services)
controller.loadViewIfNeeded()
for tab in AppTab.allCases {
XCTAssertNotNil(controller.navigationController(for: tab))
XCTAssertEqual(
controller.navigationController(for: tab)?.tabBarItem.accessibilityIdentifier,
"main.tab.\(tab.rawValue)"
)
}
}
}
/// Tab 使
private final class MainTabRecordingURLSession: URLSessionProtocol {
///
func data(for request: URLRequest) async throws -> (Data, URLResponse) {
let response = HTTPURLResponse(
url: request.url ?? URL(string: "https://example.com")!,
statusCode: 200,
httpVersion: nil,
headerFields: nil
)!
return (Data(), response)
}
}