diff --git a/build.sbt b/build.sbt index ece43e07..db852a11 100644 --- a/build.sbt +++ b/build.sbt @@ -137,8 +137,8 @@ lazy val zio = project name := "colibri-zio", libraryDependencies ++= Seq( "io.github.cquiroz" %%% "scala-java-time" % "2.5.0", - "dev.zio" %%% "zio" % "2.0.6", - "dev.zio" %%% "zio-streams" % "2.0.6", + "dev.zio" %%% "zio" % "2.0.19", + "dev.zio" %%% "zio-streams" % "2.0.19", ), ) diff --git a/zio/src/test/scala/colibri/ObservableSpec.scala b/zio/src/test/scala/colibri/ObservableSpec.scala index 6c9c230b..b5155c81 100644 --- a/zio/src/test/scala/colibri/ObservableSpec.scala +++ b/zio/src/test/scala/colibri/ObservableSpec.scala @@ -1,12 +1,23 @@ package colibri +import cats.effect.IO +import cats.effect.unsafe import zio._ -// import zio.stream.ZStream import colibri.ext.zio._ import org.scalatest.matchers.should.Matchers import org.scalatest.flatspec.AsyncFlatSpec +import java.util.concurrent.TimeUnit + class ObservableSpec extends AsyncFlatSpec with Matchers { + override val executionContext = scala.scalajs.concurrent.QueueExecutionContext() + implicit val ioRuntime: unsafe.IORuntime = unsafe.IORuntime( + compute = this.executionContext, + blocking = this.executionContext, + config = unsafe.IORuntimeConfig(), + scheduler = unsafe.IORuntime.defaultScheduler, + shutdown = () => (), + ) "Observable" should "recover after mapEffect" in { var recovered = List.empty[Throwable] @@ -76,8 +87,21 @@ class ObservableSpec extends AsyncFlatSpec with Matchers { ), ) - received shouldBe List(15, 10, 6, 3, 1, 0) + cancelable.isEmpty() shouldBe false + received shouldBe List.empty errors shouldBe 0 - cancelable.isEmpty() shouldBe true + + import scala.concurrent.duration._ + + val test = for { + //TODO: why does it need an actual delay? + _ <- IO.sleep(FiniteDuration.apply(1, TimeUnit.SECONDS)) + + _ = received shouldBe List(15, 10, 6, 3, 1, 0) + _ = errors shouldBe 0 + _ = cancelable.isEmpty() shouldBe true + } yield succeed + + test.unsafeToFuture() } }