mirror of
https://github.com/bitwarden/android.git
synced 2024-11-26 11:26:09 +03:00
Used fixed timezome to fix failing Password History test (#943)
This commit is contained in:
parent
8156e306f5
commit
a8f24f5f55
1 changed files with 17 additions and 4 deletions
|
@ -22,10 +22,13 @@ import io.mockk.runs
|
|||
import io.mockk.verify
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.time.Instant
|
||||
import java.util.TimeZone
|
||||
|
||||
class PasswordHistoryViewModelTest : BaseViewModelTest() {
|
||||
|
||||
|
@ -38,6 +41,16 @@ class PasswordHistoryViewModelTest : BaseViewModelTest() {
|
|||
every { getVaultItemStateFlow("mockId-1") } returns mutableVaultItemFlow
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
fun setUp() {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun tearDown() {
|
||||
TimeZone.setDefault(null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `initial state should be correct`() = runTest {
|
||||
val viewModel = createViewModel()
|
||||
|
@ -67,9 +80,9 @@ class PasswordHistoryViewModelTest : BaseViewModelTest() {
|
|||
|
||||
viewModel.stateFlow.test {
|
||||
val expectedState = createPasswordHistoryState(
|
||||
viewState = PasswordHistoryState.ViewState.Error(
|
||||
message = R.string.an_error_has_occurred.asText(),
|
||||
),
|
||||
viewState = PasswordHistoryState.ViewState.Error(
|
||||
message = R.string.an_error_has_occurred.asText(),
|
||||
),
|
||||
)
|
||||
val actualState = awaitItem()
|
||||
assertEquals(expectedState, actualState)
|
||||
|
@ -162,7 +175,7 @@ class PasswordHistoryViewModelTest : BaseViewModelTest() {
|
|||
passwords = listOf(
|
||||
PasswordHistoryState.GeneratedPassword(
|
||||
password = "mockPassword-1",
|
||||
date = "10/27/23 6:00 AM",
|
||||
date = "10/27/23 12:00 PM",
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue