Skip to content

Commit

Permalink
added a unit test (#2570)
Browse files Browse the repository at this point in the history
  • Loading branch information
anandwana001 authored Jul 24, 2024
1 parent b1340ef commit 34713ac
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.google.android.ground.persistence.local.LocalValueStore
import com.google.android.ground.persistence.local.stores.LocalSurveyStore
import com.google.android.ground.persistence.local.stores.LocalUserStore
import com.google.android.ground.system.NetworkManager
import com.google.android.ground.system.auth.SignInState
import com.google.common.truth.Truth.assertThat
import com.sharedtest.FakeData
import com.sharedtest.persistence.remote.FakeRemoteDataStore
Expand All @@ -29,6 +30,7 @@ import dagger.hilt.android.testing.BindValue
import dagger.hilt.android.testing.HiltAndroidTest
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.advanceUntilIdle
import org.junit.Test
import org.junit.runner.RunWith
Expand Down Expand Up @@ -117,6 +119,17 @@ class UserRepositoryTest : BaseHiltTest() {
assertThat(userRepository.canUserSubmitData()).isFalse()
}

@Test
fun `signOut() should sign out the user`() {
runWithTestDispatcher {
fakeAuthenticationManager.setUser(FakeData.USER)
fakeAuthenticationManager.setState(SignInState.SignedIn(FakeData.USER))

userRepository.signOut()
assertThat(fakeAuthenticationManager.signInState.first()).isEqualTo(SignInState.SignedOut)
}
}

@Test
fun `canUserSubmitData() when user email is empty returns false`() = runWithTestDispatcher {
val user = FakeData.USER.copy(email = "")
Expand Down

0 comments on commit 34713ac

Please sign in to comment.