Skip to content

Commit b1f7ae0

Browse files
committed
Test ComposableView emission
1 parent 4968d13 commit b1f7ae0

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

AndroidSwiftUICore/Tests/AndroidSwiftUICoreTests/EvaluatorTests.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,28 @@ struct GraphicsTests {
269269
#expect(node.props["url"] == .string("https://example.com/clip.mp4"))
270270
}
271271

272+
@Test("ComposableView emits a Composable node naming its factory with typed props")
273+
func composableView() {
274+
let node = ViewHost(
275+
ComposableView("RatingBar", props: ["rating": 3.5, "max": 5, "editable": true, "id": "abc"])
276+
).evaluate()
277+
#expect(node.type == "Composable")
278+
#expect(node.props["name"] == .string("RatingBar"))
279+
#expect(node.props["rating"] == .double(3.5))
280+
#expect(node.props["max"] == .int(5))
281+
#expect(node.props["editable"] == .bool(true))
282+
#expect(node.props["id"] == .string("abc"))
283+
}
284+
285+
@Test("ComposableView forwards child content")
286+
func composableViewChildren() {
287+
let node = ViewHost(
288+
ComposableView("DashedBorder") { Text("inside") }
289+
).evaluate()
290+
#expect(node.type == "Composable")
291+
#expect(firstTextString(node.children.first ?? node) == "inside")
292+
}
293+
272294
@Test("Overlay emits base and overlay children with alignment")
273295
func overlay() {
274296
let node = ViewHost(Color.blue.overlay(alignment: .bottomTrailing) { Text("badge") }).evaluate()

0 commit comments

Comments
 (0)