Skip to content

Commit 8859c97

Browse files
committed
WIP
1 parent 336d85a commit 8859c97

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed
Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,43 @@
11
#if !os(iOS) && !os(tvOS) && !os(visionOS)
22
import SwiftUI
33
import SwiftUIIntrospect
4-
import XCTest
4+
import Testing
55

6-
@available(macOS 12, *)
76
@MainActor
8-
final class ToggleWithButtonStyleTests: XCTestCase {
7+
@Suite
8+
struct ToggleWithButtonStyleTests {
99
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
1010
typealias PlatformToggleWithButtonStyle = NSButton
1111
#endif
1212

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
2316
VStack {
2417
Toggle("", isOn: .constant(true))
2518
.toggleStyle(.button)
2619
#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)
2821
#endif
2922

3023
Toggle("", isOn: .constant(false))
3124
.toggleStyle(.button)
3225
#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)
3427
#endif
3528

3629
Toggle("", isOn: .constant(true))
3730
.toggleStyle(.button)
3831
#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)
4033
#endif
4134
}
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
4835
}
36+
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
37+
#expect(entity1.state == .on)
38+
#expect(entity2.state == .off)
39+
#expect(entity3.state == .on)
40+
#endif
4941
}
5042
}
5143
#endif

0 commit comments

Comments
 (0)