//
//  MainTabItemTests.swift
//  suixinkanTests
//

import UIKit
import XCTest
@testable import suixinkan

/// 主 TabBar 图标与可访问性测试。
@MainActor
final class MainTabItemTests: XCTestCase {

    func testAppTabsUseRestoredAssetIconsAndBuildImages() {
        XCTAssertEqual(AppTab.home.unselectedImageName, "tab_home_unselected")
        XCTAssertEqual(AppTab.home.selectedImageName, "tab_home_selected")
        XCTAssertEqual(AppTab.orders.unselectedImageName, "tab_order_unselected")
        XCTAssertEqual(AppTab.statistics.selectedImageName, "tab_data_selected")
        XCTAssertEqual(AppTab.profile.unselectedImageName, "tab_profile_unselected")

        for tab in AppTab.allCases {
            let item = tab.makeTabBarItem()
            XCTAssertEqual(item.title, tab.title)
            XCTAssertEqual(item.accessibilityIdentifier, "main.tab.\(tab.rawValue)")
            XCTAssertNotNil(item.image)
            XCTAssertNotNil(item.selectedImage)
            XCTAssertEqual(item.image?.renderingMode, .alwaysOriginal)
            XCTAssertEqual(item.selectedImage?.renderingMode, .alwaysOriginal)
        }
    }

    func testScanTabItemBuildsGeneratedImageAndKeepsAccessibility() {
        let item = MainScanTabItem.makeTabBarItem()

        XCTAssertNil(item.title)
        XCTAssertEqual(item.accessibilityLabel, "扫码核销")
        XCTAssertEqual(item.accessibilityIdentifier, "main.scan")
        XCTAssertNotNil(item.image)
        XCTAssertNotNil(item.selectedImage)
        XCTAssertEqual(item.image?.renderingMode, .alwaysOriginal)
    }
}
