I have a custom view that gets passed some Text objects. But I can't figure out how to get the string value out of them. For example:
let text = Text("hello")
// no way to get "hello" back
I've gone through the documentation, but for some reason the properties are not publicized.
I'm not sure of the context and if this helps with your particular scenario, but I came across your post as I had just been having trouble testing a Text value.
What I worked out for me, was I could use the Text's verbatim parameter to test the String (as below):
it("should show the content I'm after") {
expect(viewModel.someText) == Text(verbatim: "some content I'm after")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With