|
1 | 1 | #if !os(iOS) && !os(tvOS) && !os(visionOS) |
2 | 2 | import SwiftUI |
3 | 3 | import SwiftUIIntrospect |
4 | | -import XCTest |
| 4 | +import Testing |
5 | 5 |
|
6 | 6 | @MainActor |
7 | | -final class ToggleWithCheckboxStyleTests: XCTestCase { |
| 7 | +@Suite |
| 8 | +struct ToggleWithCheckboxStyleTests { |
8 | 9 | #if canImport(AppKit) && !targetEnvironment(macCatalyst) |
9 | 10 | typealias PlatformToggleWithCheckboxStyle = NSButton |
10 | 11 | #endif |
11 | 12 |
|
12 | | - func testToggleWithCheckboxStyle() throws { |
13 | | - XCTAssertViewIntrospection(of: PlatformToggleWithCheckboxStyle.self) { spies in |
14 | | - let spy0 = spies[0] |
15 | | - let spy1 = spies[1] |
16 | | - let spy2 = spies[2] |
17 | | - |
| 13 | + @Test func testToggleWithCheckboxStyle() async throws { |
| 14 | + let (entity1, entity2, entity3) = try await introspection(of: PlatformToggleWithCheckboxStyle.self) { spy1, spy2, spy3 in |
18 | 15 | VStack { |
19 | 16 | Toggle("", isOn: .constant(true)) |
20 | 17 | .toggleStyle(.checkbox) |
21 | 18 | #if os(macOS) |
22 | | - .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy0) |
| 19 | + .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) |
23 | 20 | #endif |
24 | 21 |
|
25 | 22 | Toggle("", isOn: .constant(false)) |
26 | 23 | .toggleStyle(.checkbox) |
27 | 24 | #if os(macOS) |
28 | | - .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy1) |
| 25 | + .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) |
29 | 26 | #endif |
30 | 27 |
|
31 | 28 | Toggle("", isOn: .constant(true)) |
32 | 29 | .toggleStyle(.checkbox) |
33 | 30 | #if os(macOS) |
34 | | - .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy2) |
| 31 | + .introspect(.toggle(style: .checkbox), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy3) |
35 | 32 | #endif |
36 | 33 | } |
37 | | - } extraAssertions: { |
38 | | - #if canImport(AppKit) && !targetEnvironment(macCatalyst) |
39 | | - XCTAssertEqual($0[safe: 0]?.state, .on) |
40 | | - XCTAssertEqual($0[safe: 1]?.state, .off) |
41 | | - XCTAssertEqual($0[safe: 2]?.state, .on) |
42 | | - #endif |
43 | 34 | } |
| 35 | + #if canImport(AppKit) && !targetEnvironment(macCatalyst) |
| 36 | + #expect(entity1.state == .on) |
| 37 | + #expect(entity2.state == .off) |
| 38 | + #expect(entity3.state == .on) |
| 39 | + #endif |
44 | 40 | } |
45 | 41 | } |
46 | 42 | #endif |
0 commit comments