Skip to content

Commit

Permalink
#277 [test] ThrottledDuration전략 test
Browse files Browse the repository at this point in the history
  • Loading branch information
murjune committed Sep 15, 2023
1 parent 3748704 commit e922ce3
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package hous.release.designsystem.util.single_event

import com.google.common.truth.Truth
import hous.release.testing.CoroutinesTestExtension
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith

@OptIn(ExperimentalCoroutinesApi::class)
@ExtendWith(CoroutinesTestExtension::class)
internal class ThrottledDurationStrategyTest {

@Test
fun `마지막 이벤트가 발생한 지 300ms가 지나지 않고 추가 이벤트가 발생시 무시한다`() = runTest {
// given
val strategy = ThrottledDurationStrategy()
var count = 0
// when
strategy.handle {
count++
}
delay(301)
strategy.handle {
count++
}
// then
Truth.assertThat(count).isEqualTo(1)
}
}

0 comments on commit e922ce3

Please sign in to comment.