mirror of
https://github.com/phfroidmont/scalive.git
synced 2025-12-25 13:36:59 +01:00
Fix splitByIndex diff
This commit is contained in:
parent
681feced9f
commit
eab5eb3316
4 changed files with 65 additions and 21 deletions
|
|
@ -290,6 +290,48 @@ object LiveViewSpec extends TestSuite:
|
|||
)
|
||||
)
|
||||
}
|
||||
test("diff add one to empty list") {
|
||||
val model = Var(TestModel(items = List.empty))
|
||||
val el =
|
||||
div(
|
||||
ul(
|
||||
model(_.items).splitByIndex((_, elem) =>
|
||||
li(
|
||||
"Nom: ",
|
||||
elem(_.name),
|
||||
" Age: ",
|
||||
elem(_.age.toString)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
el.syncAll()
|
||||
el.setAllUnchanged()
|
||||
|
||||
model.update(_.copy(items = List(NestedModel("a", 20))))
|
||||
|
||||
assertEqualsDiff(
|
||||
el,
|
||||
Json.Obj(
|
||||
"0" ->
|
||||
Json
|
||||
.Obj(
|
||||
"s" -> Json.Arr(
|
||||
Json.Str("<li>Nom: "),
|
||||
Json.Str(" Age: "),
|
||||
Json.Str("</li>")
|
||||
),
|
||||
"k" -> Json.Obj(
|
||||
"0" -> Json.Obj(
|
||||
"0" -> Json.Str("a"),
|
||||
"1" -> Json.Str("20")
|
||||
),
|
||||
"kc" -> Json.Num(1)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
test("diff with first item removed") {
|
||||
model.update(_.copy(items = initModel.items.tail))
|
||||
assertEqualsDiff(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue