Skip to content

Commit 11e2839

Browse files
committed
fix: unit test issues in signInViewModelTest
1 parent a6579cf commit 11e2839

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

app/src/main/java/org/openedx/app/di/ScreenModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import org.openedx.profile.presentation.profile.ProfileViewModel
7777
import org.openedx.profile.presentation.settings.SettingsViewModel
7878
import org.openedx.profile.presentation.video.VideoSettingsViewModel
7979
import org.openedx.whatsnew.presentation.whatsnew.WhatsNewViewModel
80+
import android.content.res.Resources
8081

8182
val screenModule = module {
8283

@@ -109,6 +110,7 @@ val screenModule = module {
109110
)
110111
}
111112

113+
val lang = Resources.getSystem().configuration.locales[0].language
112114
viewModel { (courseId: String?, infoType: String?) ->
113115
SignInViewModel(
114116
get(),
@@ -127,6 +129,7 @@ val screenModule = module {
127129
get(),
128130
courseId,
129131
infoType,
132+
lang
130133
)
131134
}
132135

auth/src/main/java/org/openedx/auth/presentation/signin/SignInViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class SignInViewModel(
5858
config: Config,
5959
val courseId: String?,
6060
val infoType: String?,
61+
currentLang: String,
6162
) : BaseViewModel() {
6263

6364
private val logger = Logger("SignInViewModel")
@@ -66,7 +67,7 @@ class SignInViewModel(
6667
SignInUIState(
6768
isLoginRegistrationFormEnabled = config.isLoginRegistrationEnabled(),
6869
isSSOLoginEnabled = config.isSSOLoginEnabled(),
69-
ssoButtonTitle = config.getSSOButtonTitle(key = Resources.getSystem().getConfiguration().locales[0].language.uppercase(), ""),
70+
ssoButtonTitle = currentLang,
7071
isSSODefaultLoginButton = config.isSSODefaultLoginButton(),
7172
isFacebookAuthEnabled = config.getFacebookConfig().isEnabled(),
7273
isGoogleAuthEnabled = config.getGoogleConfig().isEnabled(),

auth/src/test/java/org/openedx/auth/presentation/signin/SignInViewModelTest.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class SignInViewModelTest {
9797
every { config.isRegistrationEnabled() } returns true
9898
every { config.isLoginRegistrationEnabled() } returns true
9999
every { config.isSSOLoginEnabled() } returns false
100+
every { config.isSSODefaultLoginButton() } returns false
100101
}
101102

102103
@After
@@ -126,7 +127,8 @@ class SignInViewModelTest {
126127
infoType = "",
127128
calendarInteractor = calendarInteractor,
128129
calendarPreferences = calendarPreferences,
129-
configuration = config
130+
configuration = config,
131+
currentLang = "EN"
130132
)
131133
viewModel.login("", "")
132134
coVerify(exactly = 0) { interactor.login(any(), any()) }
@@ -164,6 +166,7 @@ class SignInViewModelTest {
164166
calendarInteractor = calendarInteractor,
165167
calendarPreferences = calendarPreferences,
166168
configuration = config,
169+
currentLang = "EN"
167170
)
168171
viewModel.login("[email protected]", "")
169172
coVerify(exactly = 0) { interactor.login(any(), any()) }
@@ -201,6 +204,7 @@ class SignInViewModelTest {
201204
calendarInteractor = calendarInteractor,
202205
calendarPreferences = calendarPreferences,
203206
configuration = config,
207+
currentLang = "EN"
204208
)
205209
viewModel.login("[email protected]", "")
206210

@@ -237,6 +241,7 @@ class SignInViewModelTest {
237241
calendarInteractor = calendarInteractor,
238242
calendarPreferences = calendarPreferences,
239243
configuration = config,
244+
currentLang = "EN"
240245
)
241246
viewModel.login("[email protected]", "ed")
242247

@@ -277,6 +282,7 @@ class SignInViewModelTest {
277282
calendarInteractor = calendarInteractor,
278283
calendarPreferences = calendarPreferences,
279284
configuration = config,
285+
currentLang = "EN"
280286
)
281287
coEvery { interactor.login("[email protected]", "edx") } returns Unit
282288
viewModel.login("[email protected]", "edx")
@@ -317,6 +323,7 @@ class SignInViewModelTest {
317323
calendarInteractor = calendarInteractor,
318324
calendarPreferences = calendarPreferences,
319325
configuration = config,
326+
currentLang = "EN"
320327
)
321328
coEvery { interactor.login("[email protected]", "edx") } throws UnknownHostException()
322329
viewModel.login("[email protected]", "edx")
@@ -359,6 +366,7 @@ class SignInViewModelTest {
359366
calendarInteractor = calendarInteractor,
360367
calendarPreferences = calendarPreferences,
361368
configuration = config,
369+
currentLang = "EN"
362370
)
363371
coEvery { interactor.login("[email protected]", "edx") } throws EdxError.InvalidGrantException()
364372
viewModel.login("[email protected]", "edx")
@@ -401,6 +409,7 @@ class SignInViewModelTest {
401409
calendarInteractor = calendarInteractor,
402410
calendarPreferences = calendarPreferences,
403411
configuration = config,
412+
currentLang = "EN"
404413
)
405414
coEvery { interactor.login("[email protected]", "edx") } throws IllegalStateException()
406415
viewModel.login("[email protected]", "edx")

0 commit comments

Comments
 (0)