1
0
Fork 0
fenix/app/src/test/java/org/mozilla/fenix/loginexceptions/LoginExceptionFragmentStore...

33 lines
1.1 KiB
Kotlin
Raw Normal View History

/* 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/. */
2020-07-02 04:37:03 +02:00
package org.mozilla.fenix.loginexceptions
2020-07-02 04:37:03 +02:00
import io.mockk.mockk
import kotlinx.coroutines.runBlocking
2020-07-02 04:37:03 +02:00
import mozilla.components.feature.logins.exceptions.LoginException
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotSame
import org.junit.Test
2020-07-02 04:37:03 +02:00
class LoginExceptionFragmentStoreTest {
@Test
fun onChange() = runBlocking {
val initialState = emptyDefaultState()
val store = ExceptionsFragmentStore(initialState)
2020-07-02 04:37:03 +02:00
val newExceptionsItem: LoginException = mockk()
store.dispatch(ExceptionsFragmentAction.Change(listOf(newExceptionsItem))).join()
assertNotSame(initialState, store.state)
assertEquals(
store.state.items,
listOf(newExceptionsItem)
)
}
private fun emptyDefaultState(): ExceptionsFragmentState = ExceptionsFragmentState(
items = listOf()
)
}