From 4691c0c2d60ff8ab1a3b5e3fbe845d262b7be3f9 Mon Sep 17 00:00:00 2001 From: Veyndan Stuart Date: Wed, 13 Sep 2023 17:05:17 +0200 Subject: [PATCH] Test `itemsAfter` is set when item count is high --- .../lazylayout/compose/LazyListTest.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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 3d1fcaa9fb..ed2c6c17a4 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 @@ -61,14 +61,25 @@ class LazyListTest { } @Test - fun populatedLazyColumn() = runTest { + fun populatedLazyColumnVariesItemsAfter_0() = + populatedLazyColumnVariesItemsAfter(10, 0, 10) + + @Test + fun populatedLazyColumnVariesItemsAfter_1() = + populatedLazyColumnVariesItemsAfter(100, 85, 15) + + private fun populatedLazyColumnVariesItemsAfter( + itemCount: Int, + expectedItemsAfter: Int, + expectedItemCount: Int, + ) = runTest { val snapshot = TestSchemaTester { setContent { LazyColumn( state = rememberLazyListState(), placeholder = { Text("Placeholder") }, ) { - items(10) { + items(itemCount) { Text(it.toString()) } } @@ -83,14 +94,14 @@ class LazyListTest { isVertical = true, onViewportChanged = { _, _ -> }, itemsBefore = 0, - itemsAfter = 0, + itemsAfter = expectedItemsAfter, 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()) }, + items = List(expectedItemCount) { TextValue(Modifier, it.toString()) }, ), ) }