For #7679 - Replaced comparison by reference with value, added check for default in order to avoid double checkmark (example: default + English) (#7729)
parent
06169433b5
commit
b3d99c6bba
@ -0,0 +1,48 @@
|
||||
package org.mozilla.fenix.settings.advanced
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.mockkStatic
|
||||
import mozilla.components.support.locale.LocaleManager
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.Locale
|
||||
|
||||
class LocaleAdapterTest {
|
||||
|
||||
private val selectedLocale = Locale("en", "UK")
|
||||
private val view: View = mockk(relaxed = true)
|
||||
private val context: Context = mockk(relaxed = true)
|
||||
|
||||
private val localeViewHolder: BaseLocaleViewHolder =
|
||||
object : BaseLocaleViewHolder(view, selectedLocale) {
|
||||
|
||||
override fun bind(locale: Locale) {
|
||||
// not required
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
every { view.context } returns context
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `verify selected locale checker returns true`() {
|
||||
mockkStatic("org.mozilla.fenix.settings.advanced.LocaleManagerExtensionKt")
|
||||
every { LocaleManager.isDefaultLocaleSelected(context) } returns false
|
||||
|
||||
assertTrue(localeViewHolder.isCurrentLocaleSelected(selectedLocale, isDefault = false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `verify default locale checker returns true`() {
|
||||
mockkStatic("org.mozilla.fenix.settings.advanced.LocaleManagerExtensionKt")
|
||||
every { LocaleManager.isDefaultLocaleSelected(context) } returns true
|
||||
|
||||
assertTrue(localeViewHolder.isCurrentLocaleSelected(selectedLocale, isDefault = true))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue