Skip to content

Commit

Permalink
Merge pull request #511 from arkivanov/empty-pages-tests
Browse files Browse the repository at this point in the history
Added tests for empty Pages
  • Loading branch information
arkivanov authored Oct 24, 2023
2 parents 41c4461 + 54fb510 commit 9aacd5d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ class PagesTest {
assertContentEquals(listOf(2), indices)
}

@Test
fun GIVEN_pages_empty_WHEN_shown_THEN_onPageSelected_not_called() {
val state = mutableStateOf(ChildPages<Config, Config>())

val indices = ArrayList<Int>()

setContent(
pages = state,
onPageSelected = { indices += it },
scrollAnimation = PagesScrollAnimation.Default,
)

assertContentEquals(emptyList(), indices)
}

private fun setContent(
pages: State<ChildPages<Config, Config>>,
onPageSelected: (index: Int) -> Unit = {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class PagesTest {
assertContentEquals(listOf(2), indices)
}


@Test
fun GIVEN_pages_with_animation_WHEN_page_changed_from_0_to_2_THEN_onPageSelected_called_with_index_2() {
val state =
Expand Down Expand Up @@ -129,6 +128,20 @@ class PagesTest {
assertContentEquals(listOf(2), indices)
}

@Test
fun GIVEN_pages_empty_WHEN_shown_THEN_onPageSelected_not_called() {
val state = mutableStateOf(ChildPages<Config, Config>())

val indices = ArrayList<Int>()

setContent(
pages = state,
onPageSelected = { indices += it },
scrollAnimation = PagesScrollAnimation.Default,
)

assertContentEquals(emptyList(), indices)
}

private fun setContent(
pages: State<ChildPages<Config, Config>>,
Expand Down

0 comments on commit 9aacd5d

Please sign in to comment.