Add an accessor for the prompt when inspecting a TextField.
Given code like the following:
struct MyView: View {
@Binding var myText: String = ""
var prompt: String = ""
var body: some View {
TextField("My Label", text: $myText, prompt: self.prompt)
}
}
We would be able to do something like:
func test_promptIsCorrect() throws {
var textBinding = Binding<String>(wrappedValue: "")
let sut = MyView(prompt: "My Prompt")
let prompt = try sut.inspect().view(MyView.self).textField().prompt()
let promptText = try prompt.string()
XCTAssertEqual(promptText, "My Prompt")
}
Add an accessor for the
prompt
when inspecting aTextField
.Given code like the following:
We would be able to do something like:
Discussed in https://github.com/nalexn/ViewInspector/discussions/258