Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Add tests for setSelection
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp committed Nov 14, 2023
1 parent e25ace0 commit 3a568ec
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,19 @@ class FakeRichTextEditorStateTest {
assertThat(hasFocus, equalTo(true))
}
}

@Test
fun `setSelection updates the state`() = runTest {
moleculeFlow(RecompositionMode.Immediate) {
val state = rememberRichTextEditorState(fake = true)
remember(state.selection) { state }
}.test {
val initialState = awaitItem()
assertThat(initialState.selection, equalTo(0 to 0))
initialState.setSelection(1)
assertThat(awaitItem().selection, equalTo(1 to 1))
initialState.setSelection(0, 1)
assertThat(awaitItem().selection, equalTo(0 to 1))
}
}
}

0 comments on commit 3a568ec

Please sign in to comment.