Skip to content

Commit

Permalink
enabling the personalisation feature for registration unit tests whic…
Browse files Browse the repository at this point in the history
…h expect it to be enabled
  • Loading branch information
ouchadam committed Mar 28, 2022
1 parent b526208 commit d1bed4b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class OnboardingViewModelTest {
private val fakeActiveSessionHolder = FakeActiveSessionHolder(fakeSession)
private val fakeAuthenticationService = FakeAuthenticationService()
private val fakeRegisterActionHandler = FakeRegisterActionHandler()
private val fakeVectorFeatures = FakeVectorFeatures()

lateinit var viewModel: OnboardingViewModel

Expand Down Expand Up @@ -180,7 +181,8 @@ class OnboardingViewModelTest {
}

@Test
fun `when registering account, then updates state and emits account created event`() = runTest {
fun `given personalisation enabled, when registering account, then updates state and emits account created event`() = runTest {
fakeVectorFeatures.givenPersonalisationEnabled()
givenRegistrationResultFor(A_LOADABLE_REGISTER_ACTION, RegistrationResult.Success(fakeSession))
givenSuccessfullyCreatesAccount(A_HOMESERVER_CAPABILITIES)
val test = viewModel.test()
Expand All @@ -198,7 +200,8 @@ class OnboardingViewModelTest {
}

@Test
fun `given registration has started and has dummy step to do, when handling action, then ignores other steps and executes dummy`() = runTest {
fun `given personalisation enabled and registration has started and has dummy step to do, when handling action, then ignores other steps and executes dummy`() = runTest {
fakeVectorFeatures.givenPersonalisationEnabled()
givenSuccessfulRegistrationForStartAndDummySteps(missingStages = listOf(Stage.Dummy(mandatory = true)))
val test = viewModel.test()

Expand Down Expand Up @@ -340,7 +343,7 @@ class OnboardingViewModelTest {
ReAuthHelper(),
FakeStringProvider().instance,
FakeHomeServerHistoryService(),
FakeVectorFeatures(),
fakeVectorFeatures,
FakeAnalyticsTracker(),
fakeUriFilenameResolver.instance,
fakeRegisterActionHandler.instance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@ package im.vector.app.test.fakes

import im.vector.app.features.DefaultVectorFeatures
import im.vector.app.features.VectorFeatures
import io.mockk.every
import io.mockk.spyk

class FakeVectorFeatures : VectorFeatures by DefaultVectorFeatures()
class FakeVectorFeatures : VectorFeatures by spyk<DefaultVectorFeatures>() {

fun givenPersonalisationEnabled() {
every { isOnboardingPersonalizeEnabled() } returns true
}
}

0 comments on commit d1bed4b

Please sign in to comment.