Skip to content

Commit 37658a8

Browse files
committed
Test ComposableView action dispatch
1 parent 878a660 commit 37658a8

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

AndroidSwiftUICore/Tests/AndroidSwiftUICoreTests/EvaluatorTests.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,20 @@ struct GraphicsTests {
317317
#expect(firstTextString(node.children.first ?? node) == "inside")
318318
}
319319

320+
@Test("ComposableView actions register callbacks the factory can invoke")
321+
func composableViewActions() {
322+
var received = 0.0
323+
let host = ViewHost(
324+
ComposableView("RatingBar", actions: ["onRatingChanged": .double { received = $0 }])
325+
)
326+
let node = host.evaluate()
327+
guard case .int(let id)? = node.props["onRatingChanged"] else {
328+
Issue.record("missing action id"); return
329+
}
330+
host.callbacks.invokeDouble(Int64(id), 4.5)
331+
#expect(received == 4.5)
332+
}
333+
320334
@Test("Overlay emits base and overlay children with alignment")
321335
func overlay() {
322336
let node = ViewHost(Color.blue.overlay(alignment: .bottomTrailing) { Text("badge") }).evaluate()

0 commit comments

Comments
 (0)