-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#277 [test] ThrottledDuration전략 test
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...rc/test/java/hous/release/designsystem/util/single_event/ThrottledDurationStrategyTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |