import XCTest
import CoreBluetooth
@testable import CelestiaTrace

final class BLEFilteringTests: XCTestCase {
    func testAnonymousUnrelatedPeripheralIsRejected() {
        XCTAssertFalse(BLEManager.isSparkAdvertisement(name: nil, serviceUUIDs: []))
    }

    func testKnownServiceIsAcceptedWithoutName() {
        XCTAssertTrue(BLEManager.isSparkAdvertisement(name: nil, serviceUUIDs: [BLEManager.serviceUUID]))
    }

    func testKnownProductNamesAreAccepted() {
        XCTAssertTrue(BLEManager.isSparkAdvertisement(name: "YLF20_12345", serviceUUIDs: []))
        XCTAssertTrue(BLEManager.isSparkAdvertisement(name: "ylf20_abcde", serviceUUIDs: []))
        XCTAssertTrue(BLEManager.isSparkAdvertisement(name: "MR20", serviceUUIDs: []))
        XCTAssertTrue(BLEManager.isSparkAdvertisement(name: "Celestia Spark", serviceUUIDs: []))
        XCTAssertTrue(BLEManager.isSparkAdvertisement(name: "微光录音设备", serviceUUIDs: []))
    }

    func testUnrelatedNamedPeripheralIsRejected() {
        XCTAssertFalse(BLEManager.isSparkAdvertisement(name: "Living Room TV", serviceUUIDs: []))
    }
}
