Fix tests
This commit is contained in:
parent
2c840683eb
commit
29372c18ff
3 changed files with 50 additions and 6 deletions
|
@ -20,15 +20,18 @@ class HistoryViewModelTest : IntentViewModelTest() {
|
|||
private val allSaves = listOf(
|
||||
Save(
|
||||
0, 1, 0L, 100L, fakeMinefield,
|
||||
Difficulty.Beginner, FirstOpen.Unknown, SaveStatus.ON_GOING, listOf()
|
||||
Difficulty.Beginner, FirstOpen.Unknown, SaveStatus.ON_GOING,
|
||||
listOf(), 10
|
||||
),
|
||||
Save(
|
||||
1, 2, 0L, 100L, fakeMinefield,
|
||||
Difficulty.Beginner, FirstOpen.Unknown, SaveStatus.ON_GOING, listOf()
|
||||
Difficulty.Beginner, FirstOpen.Unknown, SaveStatus.ON_GOING,
|
||||
listOf(), 20
|
||||
),
|
||||
Save(
|
||||
2, 3, 0L, 100L, fakeMinefield,
|
||||
Difficulty.Beginner, FirstOpen.Unknown, SaveStatus.ON_GOING, listOf()
|
||||
Difficulty.Beginner, FirstOpen.Unknown, SaveStatus.ON_GOING,
|
||||
listOf(), 30
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import dev.lucasnlm.antimine.core.control.ControlStyle
|
|||
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
|
||||
|
||||
class MockPreferencesRepository : IPreferencesRepository {
|
||||
var customMinefield = Minefield(9, 9, 9)
|
||||
private var customMinefield = Minefield(9, 9, 9)
|
||||
|
||||
override fun customGameMode(): Minefield = customMinefield
|
||||
|
||||
|
@ -45,6 +45,10 @@ class MockPreferencesRepository : IPreferencesRepository {
|
|||
|
||||
override fun disableRequestRating() { }
|
||||
|
||||
override fun unlockExtras() { }
|
||||
|
||||
override fun areExtrasUnlocked(): Boolean = false
|
||||
|
||||
override fun useFlagAssistant(): Boolean = false
|
||||
|
||||
override fun useHapticFeedback(): Boolean = true
|
||||
|
|
|
@ -2,6 +2,8 @@ package dev.lucasnlm.antimine.theme
|
|||
|
||||
import dev.lucasnlm.antimine.IntentViewModelTest
|
||||
import dev.lucasnlm.antimine.common.R
|
||||
import dev.lucasnlm.antimine.core.analytics.IAnalyticsManager
|
||||
import dev.lucasnlm.antimine.core.preferences.IPreferencesRepository
|
||||
import dev.lucasnlm.antimine.core.themes.model.AppTheme
|
||||
import dev.lucasnlm.antimine.core.themes.model.AreaPalette
|
||||
import dev.lucasnlm.antimine.core.themes.model.Assets
|
||||
|
@ -126,7 +128,11 @@ class ThemeViewModelTest : IntentViewModelTest() {
|
|||
every { getTheme() } returns gardenTheme
|
||||
}
|
||||
|
||||
val viewModel = ThemeViewModel(themeRepository)
|
||||
val preferencesRepository = mockk<IPreferencesRepository> { }
|
||||
|
||||
val analyticsManager = mockk<IAnalyticsManager> { }
|
||||
|
||||
val viewModel = ThemeViewModel(themeRepository, preferencesRepository, analyticsManager)
|
||||
assertEquals(ThemeState(gardenTheme, allThemes), viewModel.singleState())
|
||||
}
|
||||
|
||||
|
@ -138,7 +144,15 @@ class ThemeViewModelTest : IntentViewModelTest() {
|
|||
every { setTheme(any()) } returns Unit
|
||||
}
|
||||
|
||||
val state = ThemeViewModel(themeRepository).run {
|
||||
val preferencesRepository = mockk<IPreferencesRepository> {
|
||||
every { areExtrasUnlocked() } returns true
|
||||
}
|
||||
|
||||
val analyticsManager = mockk<IAnalyticsManager> {
|
||||
every { sentEvent(any()) } returns Unit
|
||||
}
|
||||
|
||||
val state = ThemeViewModel(themeRepository, preferencesRepository, analyticsManager).run {
|
||||
sendEvent(ThemeEvent.ChangeTheme(darkTheme))
|
||||
singleState()
|
||||
}
|
||||
|
@ -146,4 +160,27 @@ class ThemeViewModelTest : IntentViewModelTest() {
|
|||
|
||||
verify { themeRepository.setTheme(darkTheme) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testChangeValueWithoutExtras() {
|
||||
val themeRepository = mockk<IThemeRepository> {
|
||||
every { getAllThemes() } returns allThemes
|
||||
every { getTheme() } returns gardenTheme
|
||||
every { setTheme(any()) } returns Unit
|
||||
}
|
||||
|
||||
val preferencesRepository = mockk<IPreferencesRepository> {
|
||||
every { areExtrasUnlocked() } returns false
|
||||
}
|
||||
|
||||
val analyticsManager = mockk<IAnalyticsManager> {
|
||||
every { sentEvent(any()) } returns Unit
|
||||
}
|
||||
|
||||
val state = ThemeViewModel(themeRepository, preferencesRepository, analyticsManager).run {
|
||||
sendEvent(ThemeEvent.ChangeTheme(darkTheme))
|
||||
singleState()
|
||||
}
|
||||
assertEquals(ThemeState(gardenTheme, allThemes), state)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue