You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iceraven-browser/app/src/test/java/org/mozilla/fenix/exceptions/login/LoginExceptionsViewTest.kt

64 lines
2.0 KiB
Kotlin

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.exceptions.login
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.core.view.isVisible
import androidx.recyclerview.widget.LinearLayoutManager
import io.mockk.mockk
import mozilla.components.support.test.robolectric.testContext
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class)
class LoginExceptionsViewTest {
private lateinit var parent: ViewGroup
private lateinit var interactor: LoginExceptionsInteractor
private lateinit var view: LoginExceptionsView
@Before
fun setup() {
parent = FrameLayout(testContext)
interactor = mockk()
view = LoginExceptionsView(
parent,
interactor,
)
}
@Test
fun `sets empty message text`() {
assertEquals(
"Firefox Fenix wont save passwords for sites listed here.",
view.binding.exceptionsEmptyMessage.text,
)
assertTrue(view.binding.exceptionsList.adapter is LoginExceptionsAdapter)
assertTrue(view.binding.exceptionsList.layoutManager is LinearLayoutManager)
}
@Test
fun `hide list when there are no items`() {
view.update(emptyList())
assertTrue(view.binding.exceptionsEmptyView.isVisible)
assertFalse(view.binding.exceptionsList.isVisible)
}
@Test
fun `shows list when there are items`() {
view.update(listOf(mockk()))
assertFalse(view.binding.exceptionsEmptyView.isVisible)
assertTrue(view.binding.exceptionsList.isVisible)
}
}