Skip to content

Commit

Permalink
When deserializing a MutableState, also deserialize its value
Browse files Browse the repository at this point in the history
  • Loading branch information
veyndan committed Sep 28, 2023
1 parent a48e231 commit b1e3dcc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class StateSnapshot(
return content.mapValues { entry ->
entry.value.map {
if (it.isMutableState) {
mutableStateOf(it.value)
mutableStateOf(it.value.fromJsonElement())
} else {
it.value.fromJsonElement()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class StateSnapshotTest {
val valuesMap = stateSnapshot.toValuesMap()
assertThat(valuesMap.entries.size).isEqualTo(4)
assertTrue(valuesMap["key1"]!![0] is MutableState<*>)
assertThat((valuesMap["key1"]!![0] as MutableState<*>).value).isEqualTo(JsonPrimitive(1))
assertThat((valuesMap["key1"]!![0] as MutableState<*>).value).isEqualTo(1.0)

assertThat(valuesMap["key2"]).isEqualTo(listOf(1.0))

assertThat(valuesMap["key3"]!![0] is MutableState<*>)
assertThat((valuesMap["key3"]!![0] as MutableState<*>).value).isEqualTo(JsonPrimitive("str"))
assertThat((valuesMap["key3"]!![0] as MutableState<*>).value).isEqualTo("str")

assertThat(valuesMap["key4"]).isEqualTo(listOf("str"))
}
Expand Down

0 comments on commit b1e3dcc

Please sign in to comment.