mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] Add and update tests for login address view holder
This commit is contained in:
parent
19d06041ae
commit
d195ee2f6a
@ -25,7 +25,7 @@ class LoginsListViewHolderTest {
|
|||||||
|
|
||||||
private val baseLogin = SavedLogin(
|
private val baseLogin = SavedLogin(
|
||||||
guid = "abcd",
|
guid = "abcd",
|
||||||
origin = "mozilla.org",
|
origin = "https://www.mozilla.org",
|
||||||
username = "admin",
|
username = "admin",
|
||||||
password = "password",
|
password = "password",
|
||||||
timeLastUsed = 100L,
|
timeLastUsed = 100L,
|
||||||
@ -33,32 +33,40 @@ class LoginsListViewHolderTest {
|
|||||||
|
|
||||||
private lateinit var interactor: SavedLoginsInteractor
|
private lateinit var interactor: SavedLoginsInteractor
|
||||||
private lateinit var binding: LoginsItemBinding
|
private lateinit var binding: LoginsItemBinding
|
||||||
|
private lateinit var holder: LoginsListViewHolder
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
binding = LoginsItemBinding.inflate(LayoutInflater.from(testContext))
|
binding = LoginsItemBinding.inflate(LayoutInflater.from(testContext))
|
||||||
interactor = mockk(relaxed = true)
|
interactor = mockk(relaxed = true)
|
||||||
|
holder = LoginsListViewHolder(
|
||||||
|
binding.root,
|
||||||
|
interactor,
|
||||||
|
)
|
||||||
every { testContext.components.core.icons } returns BrowserIcons(testContext, mockk(relaxed = true))
|
every { testContext.components.core.icons } returns BrowserIcons(testContext, mockk(relaxed = true))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `bind url and username`() {
|
fun `bind url and username`() {
|
||||||
val holder = LoginsListViewHolder(
|
|
||||||
binding.root,
|
|
||||||
interactor,
|
|
||||||
)
|
|
||||||
holder.bind(baseLogin)
|
holder.bind(baseLogin)
|
||||||
|
|
||||||
assertEquals("mozilla.org", binding.webAddressView.text)
|
assertEquals("mozilla.org", binding.webAddressView.text)
|
||||||
assertEquals("admin", binding.usernameView.text)
|
assertEquals("admin", binding.usernameView.text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `GIVEN url has a mobile prefix WHEN url is binded THEN mobile prefix is stripped`() {
|
||||||
|
holder.bind(baseLogin.copy(origin = "https://m.mozilla.org"))
|
||||||
|
|
||||||
|
assertEquals("mozilla.org", binding.webAddressView.text)
|
||||||
|
|
||||||
|
holder.bind(baseLogin.copy(origin = "https://mobile.mozilla.org"))
|
||||||
|
|
||||||
|
assertEquals("mozilla.org", binding.webAddressView.text)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `call interactor on click`() {
|
fun `call interactor on click`() {
|
||||||
val holder = LoginsListViewHolder(
|
|
||||||
binding.root,
|
|
||||||
interactor,
|
|
||||||
)
|
|
||||||
holder.bind(baseLogin)
|
holder.bind(baseLogin)
|
||||||
|
|
||||||
binding.root.performClick()
|
binding.root.performClick()
|
||||||
|
Loading…
Reference in New Issue
Block a user