Skip to content

Commit 12c6a48

Browse files
committed
Test that forked exceptions reappear on await
1 parent 26f9d0c commit 12c6a48

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

test/src/test/scala/japgolly/scalajs/react/core/AsyncCallbackTest.scala

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,24 @@ object AsyncCallbackTest extends TestSuite {
153153
assertEq(i, 2)
154154
}
155155

156-
"fork" - asyncTest {
157-
for {
158-
(task, completeTask) <- AsyncCallback.promise[Int].asAsyncCallback
159-
forked <- task.fork.asAsyncCallback
160-
_ <- forked.isComplete.asAsyncCallback.tap(assertEq(_, false))
161-
_ <- completeTask(Success(123)).asAsyncCallback
162-
_ <- forked.await.tap(assertEq(_, 123))
163-
_ <- forked.isComplete.asAsyncCallback.tap(assertEq(_, true))
164-
} yield ()
156+
"fork" - {
157+
"ok" - asyncTest {
158+
for {
159+
(task, completeTask) <- AsyncCallback.promise[Int].asAsyncCallback
160+
forked <- task.fork.asAsyncCallback
161+
_ <- forked.isComplete.asAsyncCallback.tap(assertEq(_, false))
162+
_ <- completeTask(Success(123)).asAsyncCallback
163+
_ <- forked.await.tap(assertEq(_, 123))
164+
_ <- forked.isComplete.asAsyncCallback.tap(assertEq(_, true))
165+
} yield ()
166+
}
167+
168+
"ko" - asyncTest {
169+
for {
170+
f <- AsyncCallback.throwException[Int](new RuntimeException("argh")).delayMs(1).fork.asAsyncCallback
171+
t <- f.await.attemptTry
172+
} yield assert(t.isFailure)
173+
}
165174
}
166175

167176
"countDownLatch" - {

0 commit comments

Comments
 (0)