From ec445d44ecc6e7435447d972cad631146c3fc93d Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Thu, 6 Jul 2023 15:59:52 -0400 Subject: [PATCH] Test that JS frame clock sends nanos --- .../molecule/WindowAnimationFrameClockTest.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/molecule-runtime/src/jsTest/kotlin/app/cash/molecule/WindowAnimationFrameClockTest.kt b/molecule-runtime/src/jsTest/kotlin/app/cash/molecule/WindowAnimationFrameClockTest.kt index cd05f9af..ee7b0425 100644 --- a/molecule-runtime/src/jsTest/kotlin/app/cash/molecule/WindowAnimationFrameClockTest.kt +++ b/molecule-runtime/src/jsTest/kotlin/app/cash/molecule/WindowAnimationFrameClockTest.kt @@ -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 { + isPositive() + isLessThan(frameTimeB) } - job.join() } }