main.kotlin.com.intuit.playerui.utils.test.PromiseUtils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of testutils Show documentation
Show all versions of testutils Show documentation
A cross-platform semantic rendering engine
package com.intuit.playerui.utils.test
import com.intuit.playerui.core.bridge.Promise
import com.intuit.playerui.core.bridge.then
import kotlinx.serialization.DeserializationStrategy
import org.junit.jupiter.api.Assertions
public interface PromiseUtils {
public val thenChain: MutableList
public val catchChain: MutableList
public fun assertThen(vararg expected: Any?): Unit = assertChain(
thenChain,
*expected,
)
public fun assertCatch(vararg expected: Any?): Unit = assertChain(
catchChain.map {
when (it) {
is Throwable -> it.message
else -> it
}
},
*expected,
)
public fun assertChain(chain: List, vararg expected: Any?): Unit =
Assertions.assertEquals(expected.asList(), chain)
public val Promise.thenRecord: Promise get() = thenRecord()
public fun Promise.thenRecord(): Promise = thenRecord(thenChain)
public fun Promise.thenRecord(deserializer: DeserializationStrategy): Promise = thenRecord(deserializer, thenChain)
public fun Promise.thenRecord(list: MutableList): Promise = then { it: Any? -> list.add(it) }
public fun Promise.thenRecord(deserializer: DeserializationStrategy, list: MutableList): Promise = then(deserializer) { list.add(it) }
public val Promise.catchRecord: Promise get() = catchRecord()
public fun Promise.catchRecord(): Promise = catchRecord(catchChain)
public fun Promise.catchRecord(list: MutableList): Promise = catch { list.add(it) }
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy