|
|
|
@ -11,9 +11,7 @@ import mozilla.components.concept.sync.OAuthAccount
|
|
|
|
|
import mozilla.components.concept.sync.Profile
|
|
|
|
|
import mozilla.components.service.fxa.manager.FxaAccountManager
|
|
|
|
|
import org.junit.Assert.assertEquals
|
|
|
|
|
import org.junit.Assert.assertFalse
|
|
|
|
|
import org.junit.Assert.assertSame
|
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
|
import org.junit.Before
|
|
|
|
|
import org.junit.Test
|
|
|
|
|
import org.junit.runner.RunWith
|
|
|
|
@ -64,42 +62,6 @@ class FenixAccountManagerTest {
|
|
|
|
|
assertEquals(null, result)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `GIVEN an account is signed in and authenticated THEN check returns true`() {
|
|
|
|
|
every { accountManagerComponent.authenticatedAccount() } returns account
|
|
|
|
|
every { accountManagerComponent.accountNeedsReauth() } returns false
|
|
|
|
|
every { context.components.backgroundServices.accountManager } returns accountManagerComponent
|
|
|
|
|
|
|
|
|
|
fenixFxaManager = FenixAccountManager(context)
|
|
|
|
|
|
|
|
|
|
val signedIn = fenixFxaManager.signedInToFxa()
|
|
|
|
|
assertTrue(signedIn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `GIVEN an account is signed in and NOT authenticated THEN check returns false`() {
|
|
|
|
|
every { accountManagerComponent.authenticatedAccount() } returns account
|
|
|
|
|
every { accountManagerComponent.accountNeedsReauth() } returns true
|
|
|
|
|
every { context.components.backgroundServices.accountManager } returns accountManagerComponent
|
|
|
|
|
|
|
|
|
|
fenixFxaManager = FenixAccountManager(context)
|
|
|
|
|
|
|
|
|
|
val signedIn = fenixFxaManager.signedInToFxa()
|
|
|
|
|
assertFalse(signedIn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `GIVEN an account is not signed in THEN check returns false`() {
|
|
|
|
|
every { accountManagerComponent.authenticatedAccount() } returns null
|
|
|
|
|
every { accountManagerComponent.accountNeedsReauth() } returns true
|
|
|
|
|
every { context.components.backgroundServices.accountManager } returns accountManagerComponent
|
|
|
|
|
|
|
|
|
|
fenixFxaManager = FenixAccountManager(context)
|
|
|
|
|
|
|
|
|
|
val signedIn = fenixFxaManager.signedInToFxa()
|
|
|
|
|
assertFalse(signedIn)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `GIVEN no account exists WHEN accountState is called THEN it returns AccountState#NO_ACCOUNT`() {
|
|
|
|
|
every { context.components.backgroundServices.accountManager } returns accountManagerComponent
|
|
|
|
|