From a7d3a6f19f47764521b8bbdb894b0ced4837c4eb Mon Sep 17 00:00:00 2001 From: Veyndan Stuart Date: Wed, 13 Sep 2023 13:33:29 +0200 Subject: [PATCH] Test `WidgetValue` correct when `LazyColumn` is populated --- .../lazylayout/compose/LazyListTest.kt | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/redwood-lazylayout-compose/src/commonTest/kotlin/app/cash/redwood/lazylayout/compose/LazyListTest.kt b/redwood-lazylayout-compose/src/commonTest/kotlin/app/cash/redwood/lazylayout/compose/LazyListTest.kt index a13599884e..3d1fcaa9fb 100644 --- a/redwood-lazylayout-compose/src/commonTest/kotlin/app/cash/redwood/lazylayout/compose/LazyListTest.kt +++ b/redwood-lazylayout-compose/src/commonTest/kotlin/app/cash/redwood/lazylayout/compose/LazyListTest.kt @@ -59,4 +59,39 @@ class LazyListTest { ), ) } + + @Test + fun populatedLazyColumn() = runTest { + val snapshot = TestSchemaTester { + setContent { + LazyColumn( + state = rememberLazyListState(), + placeholder = { Text("Placeholder") }, + ) { + items(10) { + Text(it.toString()) + } + } + } + awaitSnapshot() + } + + assertThat(snapshot) + .containsExactly( + LazyListValue( + Modifier, + isVertical = true, + onViewportChanged = { _, _ -> }, + itemsBefore = 0, + itemsAfter = 0, + width = Constraint.Wrap, + height = Constraint.Wrap, + margin = Margin(0.0.dp), + crossAxisAlignment = CrossAxisAlignment.Start, + scrollItemIndex = ScrollItemIndex(0, 0), + placeholder = List(20) { TextValue(Modifier, "Placeholder") }, + items = List(10) { TextValue(Modifier, it.toString()) }, + ), + ) + } }