Test and document using introspectButton for Toggle on macOS (#92)

This commit is contained in:
JannThomas 2021-03-24 18:34:33 +01:00 committed by GitHub
parent f30eea5234
commit 83d06a67af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -214,6 +214,18 @@ private struct ButtonTestView: View {
}
}
@available(macOS 10.15.0, *)
private struct ToggleTestView: View {
let spy: () -> Void
@State private var toggleValue = false
var body: some View {
Toggle("Toggle", isOn: $toggleValue)
.introspectButton { button in
self.spy()
}
}
}
@available(macOS 11.0, *)
private struct ColorWellTestView: View {
@State private var color = Color.black
@ -381,6 +393,16 @@ class AppKitTests: XCTestCase {
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
}
func testToggle() {
let expectation = XCTestExpectation()
let view = ToggleTestView(spy: {
expectation.fulfill()
})
TestUtils.present(view: view)
wait(for: [expectation], timeout: TestUtils.Constants.timeout)
}
func testColorPicker() {
if #available(macOS 11.0, *) {

View File

@ -57,7 +57,7 @@ List | UITableView | NSTableView | `.introspectTableView()`
View in List | UITableViewCell | NSTableCellView | `introspectTableViewCell()`
TabView | UITabBarController | NSTabView | `.introspectTabBarController()` (iOS) <br/> `.introspectTabView()` (macOS)
TextField | UITextField | NSTextField | `.introspectTextField()`
Toggle | UISwitch | _N/A_ | `.introspectSwitch()`
Toggle | UISwitch | NSButton | `.introspectSwitch()` (iOS) <br/> `.introspectButton()` (macOS)
Slider | UISlider | NSSlider | `.introspectSlider()`
Stepper | UIStepper | NSStepper | `.introspectStepper()`
DatePicker | UIDatePicker | NSDatePicker | `.introspectDatePicker()`
@ -197,4 +197,4 @@ $ bundle exec pod trunk push .
[Siteline_Badge]: https://badgen.net/badge/Built%20by/Siteline/blue?icon=https://uploads-ssl.webflow.com/5f4513afbbfc64c4777fcccf/5f525b122370d681879e170e_siteline-icon.svg
[Quintschaf_Badge]: https://badgen.net/badge/Maintained%20by/Quintschaf/cyan?icon=https://quintschaf.com/assets/logo.svg
[Quintschaf_Badge]: https://badgen.net/badge/Maintained%20by/Quintschaf/cyan?icon=https://quintschaf.com/assets/logo.svg