Skip to content

Commit

Permalink
add withRenderedAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
rpiaggio committed Dec 29, 2024
1 parent 9b8b79c commit e6bc306
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,12 @@ trait ReactTestUtils2 extends japgolly.scalajs.react.test.internal.ReactTestUtil
F.flatMap(F.pure(ReactTestUtils2.withReactRoot.setup(implicitly, new WithDsl.Cleanup)))(
root => F.map(actAsync(root.render(unmounted)))(_ => root.selectFirstChild())
)

def withRenderedAsync[F[_], A](
unmounted: A
)(use: TestDomWithRoot => F[Unit]
)(implicit F: Async[F], renderable: Renderable[A]): F[Unit] =
F.flatMap(renderAsync(unmounted)) { d =>
F.finallyRun(use(d), actAsync(d.unmount()))
}
}

0 comments on commit e6bc306

Please sign in to comment.