Skip to content

Commit

Permalink
Use strict Abortable factory
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky committed Oct 9, 2024
1 parent 87b4956 commit 570dec9
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.test.example

import js.objects.jso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
import web.abort.AbortController
import web.abort.Abortable
import web.timers.test.awaitTimeout
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -53,7 +53,7 @@ class MyCancellationResponseLibraryTest {

assertNotNull(data)

val rejectException = data?.exceptionOrNull()
val rejectException = data.exceptionOrNull()
assertNotNull(rejectException)
assertEquals(
"REQUEST TIMEOUT ERROR",
Expand All @@ -76,30 +76,26 @@ class MyCancellationResponseLibraryTest {
@Test
fun testGetCancellableResponseOnlyWithOptions_emptyOptions() =
runCancellationTest {
getCancellableResponseOnlyWithOptions(jso())
getCancellableResponseOnlyWithOptions(Abortable())
}

@Test
fun testGetCancellableResponseOnlyWithOptions_emptyOptions_lateCancellation() =
runLateCancellationTest {
getCancellableResponseOnlyWithOptions(jso())
getCancellableResponseOnlyWithOptions(Abortable())
}

@Test
fun testGetCancellableResponseOnlyWithOptions_customSignal() =
runCancellationTest {
val controller = AbortController()
getCancellableResponseOnlyWithOptions(jso {
signal = controller.signal
})
getCancellableResponseOnlyWithOptions(Abortable(signal = controller.signal))
}

@Test
fun testGetCancellableResponseOnlyWithOptions_customSignal_lateCancellation() =
runLateCancellationTest {
val controller = AbortController()
getCancellableResponseOnlyWithOptions(jso {
signal = controller.signal
})
getCancellableResponseOnlyWithOptions(Abortable(signal = controller.signal))
}
}

0 comments on commit 570dec9

Please sign in to comment.