Skip to content

Commit

Permalink
remove Observable.lens test because does not exist anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
cornerman committed Nov 10, 2023
1 parent 67a35dd commit 6a0bd85
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions colibri/src/test/scala/colibri/ObservableSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1824,52 +1824,4 @@ class ObservableSpec extends AsyncFlatSpec with Matchers {
errors shouldBe 0
cancelable.isEmpty() shouldBe true
}

it should "lens" in {
case class Recipe(user: String, age: Int)

var receivedString = List.empty[String]
var receivedRecipe = List.empty[Recipe]
var errors = 0

val hdlRecipe = Subject.behavior[Recipe](Recipe("hans", 12))

val hdlUser = hdlRecipe.lens[String](_.user)((state, newState) => state.copy(user = newState))

hdlRecipe.unsafeSubscribe(
Observer.create[Recipe](
receivedRecipe ::= _,
_ => errors += 1,
),
)

hdlUser.unsafeSubscribe(
Observer.create[String](
receivedString ::= _,
_ => errors += 1,
),
)

receivedString shouldBe List("hans")
receivedRecipe shouldBe List(Recipe("hans", 12))
errors shouldBe 0

hdlRecipe.unsafeOnNext(Recipe("hans", 13))

receivedString shouldBe List("hans", "hans")
receivedRecipe shouldBe List(Recipe("hans", 13), Recipe("hans", 12))
errors shouldBe 0

hdlRecipe.unsafeOnNext(Recipe("gisela", 14))

receivedString shouldBe List("gisela", "hans", "hans")
receivedRecipe shouldBe List(Recipe("gisela", 14), Recipe("hans", 13), Recipe("hans", 12))
errors shouldBe 0

hdlUser.unsafeOnNext("dieter")

receivedString shouldBe List("dieter", "gisela", "hans", "hans")
receivedRecipe shouldBe List(Recipe("dieter", 14), Recipe("gisela", 14), Recipe("hans", 13), Recipe("hans", 12))
errors shouldBe 0
}
}

0 comments on commit 6a0bd85

Please sign in to comment.