Skip to content

Commit

Permalink
test: updated compose tests
Browse files Browse the repository at this point in the history
  • Loading branch information
programadorthi committed Jun 19, 2024
1 parent 6028fcd commit fc407d9
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ internal class ComposeValueManagerTest {
fun shouldRegisterToRestoration() {
val stateRestorationKey = "key#123"
val stateRegistry = FakeSaveableStateRegistry()
val expectKey = "dev.programadorthi.state.compose.ComposeValueManagerState:$stateRestorationKey"

composeValueManager(
initialValue = 0,
Expand All @@ -125,7 +126,7 @@ internal class ComposeValueManagerTest {
)

assertEquals(
stateRestorationKey,
expectKey,
stateRegistry.consumeRestoredKey,
"Consuming different keys is wrong"
)
Expand All @@ -141,7 +142,7 @@ internal class ComposeValueManagerTest {
)

assertEquals(
"myName",
"dev.programadorthi.state.compose.ComposeValueManagerState:myName",
stateRegistry.consumeRestoredKey,
"Consuming different property keys is wrong"
)
Expand All @@ -153,6 +154,7 @@ internal class ComposeValueManagerTest {
fun shouldRegisterRestorationProvider() {
val stateRestorationKey = "key#123"
val stateRegistry = FakeSaveableStateRegistry()
val expectKey = "dev.programadorthi.state.compose.ComposeValueManagerState:$stateRestorationKey"
stateRegistry.canBeSaved = true

composeValueManager(
Expand All @@ -162,13 +164,13 @@ internal class ComposeValueManagerTest {
)

assertEquals(
stateRestorationKey,
expectKey,
stateRegistry.consumeRestoredKey,
"Consuming different keys is wrong"
)
assertEquals(0, stateRegistry.canBeSavedValue, "Saved values are different")
assertEquals(
stateRestorationKey,
expectKey,
stateRegistry.entry?.key,
"Registering providers with different keys"
)
Expand All @@ -179,6 +181,7 @@ internal class ComposeValueManagerTest {
fun shouldRestorePreviousValue() {
val stateRestorationKey = "key#123"
val stateRegistry = FakeSaveableStateRegistry()
val expectKey = "dev.programadorthi.state.compose.ComposeValueManagerState:$stateRestorationKey"
stateRegistry.canBeSaved = true
stateRegistry.consumeRestored = 2024

Expand All @@ -190,13 +193,13 @@ internal class ComposeValueManagerTest {

assertEquals(2024, manager.value, "Value not restored correctly")
assertEquals(
stateRestorationKey,
expectKey,
stateRegistry.consumeRestoredKey,
"Consuming different keys is wrong"
)
assertEquals(2024, stateRegistry.canBeSavedValue, "Different can be saved values")
assertEquals(
stateRestorationKey,
expectKey,
stateRegistry.entry?.key,
"Registering providers with different keys"
)
Expand Down

0 comments on commit fc407d9

Please sign in to comment.