Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test that JS frame clock sends nanos #261

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@
*/
package app.cash.molecule

import assertk.all
import assertk.assertThat
import assertk.assertions.isLessThan
import assertk.assertions.isPositive
import kotlin.test.Test
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.test.runTest

@OptIn(ExperimentalCoroutinesApi::class)
class WindowAnimationFrameClockTest {
@Test fun ticks() = runTest {
val job = Job()
WindowAnimationFrameClock.withFrameNanos {
job.complete()
@Test fun ticksWithTime() = runTest {
val frameTimeA = WindowAnimationFrameClock.withFrameNanos { it }
val frameTimeB = WindowAnimationFrameClock.withFrameNanos { it }
assertThat(frameTimeA).all {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all is fun

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. It defers throwing until the end of the block and aggregates any failures. Very useful.

isPositive()
isLessThan(frameTimeB)
}
job.join()
}
}