Skip to content

Commit 1c9304c

Browse files
committed
Add unit test on DefaultRageshakeFeatureAvailability
1 parent 67e27ab commit 1c9304c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2025 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
5+
* Please see LICENSE files in the repository root for full details.
6+
*/
7+
8+
package io.element.android.features.rageshake.impl
9+
10+
import app.cash.turbine.test
11+
import com.google.common.truth.Truth.assertThat
12+
import kotlinx.coroutines.flow.MutableStateFlow
13+
import kotlinx.coroutines.test.runTest
14+
import okhttp3.HttpUrl
15+
import okhttp3.HttpUrl.Companion.toHttpUrl
16+
import org.junit.Test
17+
18+
class DefaultRageshakeFeatureAvailabilityTest {
19+
@Test
20+
fun `test isAvailable returns true when bug reporter URL is provided`() = runTest {
21+
val flow = MutableStateFlow<HttpUrl?>(null)
22+
val sut = DefaultRageshakeFeatureAvailability(
23+
bugReporterUrlProvider = { flow },
24+
)
25+
sut.isAvailable().test {
26+
assertThat(awaitItem()).isFalse()
27+
flow.value = "https://example.com/bugreport".toHttpUrl()
28+
assertThat(awaitItem()).isTrue()
29+
flow.value = null
30+
assertThat(awaitItem()).isFalse()
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)