Skip to content

Commit 795ad88

Browse files
committed
Test ComposableView action dispatch
1 parent 757eb42 commit 795ad88

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
@@ -291,6 +291,20 @@ struct GraphicsTests {
291291
#expect(firstTextString(node.children.first ?? node) == "inside")
292292
}
293293

294+
@Test("ComposableView actions register callbacks the factory can invoke")
295+
func composableViewActions() {
296+
var received = 0.0
297+
let host = ViewHost(
298+
ComposableView("RatingBar", actions: ["onRatingChanged": .double { received = $0 }])
299+
)
300+
let node = host.evaluate()
301+
guard case .int(let id)? = node.props["onRatingChanged"] else {
302+
Issue.record("missing action id"); return
303+
}
304+
host.callbacks.invokeDouble(Int64(id), 4.5)
305+
#expect(received == 4.5)
306+
}
307+
294308
@Test("Overlay emits base and overlay children with alignment")
295309
func overlay() {
296310
let node = ViewHost(Color.blue.overlay(alignment: .bottomTrailing) { Text("badge") }).evaluate()

0 commit comments

Comments
 (0)