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.
65 lines
2.0 KiB
Kotlin
65 lines
2.0 KiB
Kotlin
4 years ago
|
/* 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/. */
|
||
|
|
||
4 years ago
|
package org.mozilla.fenix.exceptions.login
|
||
4 years ago
|
|
||
|
import android.view.ViewGroup
|
||
|
import android.widget.FrameLayout
|
||
|
import androidx.core.view.isVisible
|
||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||
|
import io.mockk.mockk
|
||
|
import kotlinx.android.synthetic.main.component_exceptions.*
|
||
|
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()
|
||
4 years ago
|
view = LoginExceptionsView(
|
||
|
parent,
|
||
|
interactor
|
||
|
)
|
||
4 years ago
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `sets empty message text`() {
|
||
|
assertEquals(
|
||
|
"Logins and passwords that are not saved will be shown here.",
|
||
|
view.exceptions_empty_message.text
|
||
|
)
|
||
|
assertTrue(view.exceptions_list.adapter is LoginExceptionsAdapter)
|
||
|
assertTrue(view.exceptions_list.layoutManager is LinearLayoutManager)
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `hide list when there are no items`() {
|
||
4 years ago
|
view.update(emptyList())
|
||
4 years ago
|
|
||
|
assertTrue(view.exceptions_empty_view.isVisible)
|
||
|
assertFalse(view.exceptions_list.isVisible)
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun `shows list when there are items`() {
|
||
4 years ago
|
view.update(listOf(mockk()))
|
||
4 years ago
|
|
||
|
assertFalse(view.exceptions_empty_view.isVisible)
|
||
|
assertTrue(view.exceptions_list.isVisible)
|
||
|
}
|
||
|
}
|