|
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 | | -@available(macOS 12, *) |
7 | 6 | @MainActor |
8 | | -final class ToggleWithButtonStyleTests: XCTestCase { |
| 7 | +@Suite |
| 8 | +struct ToggleWithButtonStyleTests { |
9 | 9 | #if canImport(AppKit) && !targetEnvironment(macCatalyst) |
10 | 10 | typealias PlatformToggleWithButtonStyle = NSButton |
11 | 11 | #endif |
12 | 12 |
|
13 | | - func testToggleWithButtonStyle() throws { |
14 | | - guard #available(macOS 12, *) else { |
15 | | - throw XCTSkip() |
16 | | - } |
17 | | - |
18 | | - XCTAssertViewIntrospection(of: PlatformToggleWithButtonStyle.self) { spies in |
19 | | - let spy0 = spies[0] |
20 | | - let spy1 = spies[1] |
21 | | - let spy2 = spies[2] |
22 | | - |
| 13 | + @available(macOS 12, *) |
| 14 | + @Test func introspect() async throws { |
| 15 | + let (entity1, entity2, entity3) = try await introspection(of: PlatformToggleWithButtonStyle.self) { spy1, spy2, spy3 in |
23 | 16 | VStack { |
24 | 17 | Toggle("", isOn: .constant(true)) |
25 | 18 | .toggleStyle(.button) |
26 | 19 | #if os(macOS) |
27 | | - .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy0) |
| 20 | + .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) |
28 | 21 | #endif |
29 | 22 |
|
30 | 23 | Toggle("", isOn: .constant(false)) |
31 | 24 | .toggleStyle(.button) |
32 | 25 | #if os(macOS) |
33 | | - .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy1) |
| 26 | + .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) |
34 | 27 | #endif |
35 | 28 |
|
36 | 29 | Toggle("", isOn: .constant(true)) |
37 | 30 | .toggleStyle(.button) |
38 | 31 | #if os(macOS) |
39 | | - .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy2) |
| 32 | + .introspect(.toggle(style: .button), on: .macOS(.v12, .v13, .v14, .v15, .v26), customize: spy3) |
40 | 33 | #endif |
41 | 34 | } |
42 | | - } extraAssertions: { |
43 | | - #if canImport(AppKit) && !targetEnvironment(macCatalyst) |
44 | | - XCTAssertEqual($0[safe: 0]?.state, .on) |
45 | | - XCTAssertEqual($0[safe: 1]?.state, .off) |
46 | | - XCTAssertEqual($0[safe: 2]?.state, .on) |
47 | | - #endif |
48 | 35 | } |
| 36 | + #if canImport(AppKit) && !targetEnvironment(macCatalyst) |
| 37 | + #expect(entity1.state == .on) |
| 38 | + #expect(entity2.state == .off) |
| 39 | + #expect(entity3.state == .on) |
| 40 | + #endif |
49 | 41 | } |
50 | 42 | } |
51 | 43 | #endif |
0 commit comments