11#if !os(iOS) && !os(tvOS) && !os(visionOS)
22import SwiftUI
33import SwiftUIIntrospect
4- import XCTest
4+ import Testing
55
66@MainActor
7- final class PickerWithMenuStyleTests : XCTestCase {
7+ @Suite
8+ struct PickerWithMenuStyleTests {
89 #if canImport(AppKit) && !targetEnvironment(macCatalyst)
910 typealias PlatformPickerWithMenuStyle = NSPopUpButton
1011 #endif
1112
12- func testPickerWithMenuStyle( ) {
13- XCTAssertViewIntrospection ( of: PlatformPickerWithMenuStyle . self) { spies in
14- let spy0 = spies [ 0 ]
15- let spy1 = spies [ 1 ]
16- let spy2 = spies [ 2 ]
17-
13+ @Test func introspect( ) async throws {
14+ let ( entity1, entity2, entity3) = try await introspection ( of: PlatformPickerWithMenuStyle . self) { spy1, spy2, spy3 in
1815 VStack {
1916 Picker ( " Pick " , selection: . constant( " 1 " ) ) {
2017 Text ( " 1 " ) . tag ( " 1 " )
2118 }
2219 . pickerStyle ( . menu)
2320 #if os(macOS)
24- . introspect( . picker( style: . menu) , on: . macOS( . v11, . v12, . v13, . v14, . v15, . v26) , customize: spy0 )
21+ . introspect( . picker( style: . menu) , on: . macOS( . v11, . v12, . v13, . v14, . v15, . v26) , customize: spy1 )
2522 #endif
2623 . cornerRadius( 8 )
2724
@@ -31,7 +28,7 @@ final class PickerWithMenuStyleTests: XCTestCase {
3128 }
3229 . pickerStyle ( . menu)
3330 #if os(macOS)
34- . introspect( . picker( style: . menu) , on: . macOS( . v11, . v12, . v13, . v14, . v15, . v26) , customize: spy1 )
31+ . introspect( . picker( style: . menu) , on: . macOS( . v11, . v12, . v13, . v14, . v15, . v26) , customize: spy2 )
3532 #endif
3633 . cornerRadius( 8 )
3734
@@ -42,16 +39,15 @@ final class PickerWithMenuStyleTests: XCTestCase {
4239 }
4340 . pickerStyle ( . menu)
4441 #if os(macOS)
45- . introspect( . picker( style: . menu) , on: . macOS( . v11, . v12, . v13, . v14, . v15, . v26) , customize: spy2 )
42+ . introspect( . picker( style: . menu) , on: . macOS( . v11, . v12, . v13, . v14, . v15, . v26) , customize: spy3 )
4643 #endif
4744 }
48- } extraAssertions: {
49- #if canImport(AppKit) && !targetEnvironment(macCatalyst)
50- XCTAssertEqual ( $0 [ safe: 0 ] ? . numberOfItems, 1 )
51- XCTAssertEqual ( $0 [ safe: 1 ] ? . numberOfItems, 2 )
52- XCTAssertEqual ( $0 [ safe: 2 ] ? . numberOfItems, 3 )
53- #endif
5445 }
46+ #if canImport(AppKit) && !targetEnvironment(macCatalyst)
47+ #expect( entity1. numberOfItems == 1 )
48+ #expect( entity2. numberOfItems == 2 )
49+ #expect( entity3. numberOfItems == 3 )
50+ #endif
5551 }
5652}
5753#endif
0 commit comments