Skip to content

Commit 83d06a6

Browse files
authored
Test and document using introspectButton for Toggle on macOS (#92)
1 parent f30eea5 commit 83d06a6

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

IntrospectTests/AppKitTests.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,18 @@ private struct ButtonTestView: View {
214214
}
215215
}
216216

217+
@available(macOS 10.15.0, *)
218+
private struct ToggleTestView: View {
219+
let spy: () -> Void
220+
@State private var toggleValue = false
221+
var body: some View {
222+
Toggle("Toggle", isOn: $toggleValue)
223+
.introspectButton { button in
224+
self.spy()
225+
}
226+
}
227+
}
228+
217229
@available(macOS 11.0, *)
218230
private struct ColorWellTestView: View {
219231
@State private var color = Color.black
@@ -381,6 +393,16 @@ class AppKitTests: XCTestCase {
381393
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
382394
}
383395

396+
func testToggle() {
397+
398+
let expectation = XCTestExpectation()
399+
let view = ToggleTestView(spy: {
400+
expectation.fulfill()
401+
})
402+
TestUtils.present(view: view)
403+
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
404+
}
405+
384406
func testColorPicker() {
385407

386408
if #available(macOS 11.0, *) {

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ List | UITableView | NSTableView | `.introspectTableView()`
5757
View in List | UITableViewCell | NSTableCellView | `introspectTableViewCell()`
5858
TabView | UITabBarController | NSTabView | `.introspectTabBarController()` (iOS) <br/> `.introspectTabView()` (macOS)
5959
TextField | UITextField | NSTextField | `.introspectTextField()`
60-
Toggle | UISwitch | _N/A_ | `.introspectSwitch()`
60+
Toggle | UISwitch | NSButton | `.introspectSwitch()` (iOS) <br/> `.introspectButton()` (macOS)
6161
Slider | UISlider | NSSlider | `.introspectSlider()`
6262
Stepper | UIStepper | NSStepper | `.introspectStepper()`
6363
DatePicker | UIDatePicker | NSDatePicker | `.introspectDatePicker()`
@@ -197,4 +197,4 @@ $ bundle exec pod trunk push .
197197

198198
[Siteline_Badge]: https://badgen.net/badge/Built%20by/Siteline/blue?icon=https://uploads-ssl.webflow.com/5f4513afbbfc64c4777fcccf/5f525b122370d681879e170e_siteline-icon.svg
199199

200-
[Quintschaf_Badge]: https://badgen.net/badge/Maintained%20by/Quintschaf/cyan?icon=https://quintschaf.com/assets/logo.svg
200+
[Quintschaf_Badge]: https://badgen.net/badge/Maintained%20by/Quintschaf/cyan?icon=https://quintschaf.com/assets/logo.svg

0 commit comments

Comments
 (0)