Password complexity: real-time validation UI on register, onboarding, and reset screens (uppercase, lowercase, digit, min 8 chars) — Compose + iOS Swift iOS privacy descriptions: camera, photo library, photo save usage strings Token refresh: Ktor interceptor catches 401 "token_expired", refreshes, retries Retry with backoff: 3 retries on 5xx/IO errors, exponential delay (1s base, 10s max) Gzip: ContentEncoding plugin on all platform HTTP clients Request timeouts: 30s request, 10s connect, 30s socket Validation rules: split passwordMissingLetter into uppercase/lowercase (iOS Swift) Test fixes: corrected import paths in 5 existing test files New tests: HTTP client retry/refresh (9), validation rules
83 lines
1.7 KiB
Kotlin
83 lines
1.7 KiB
Kotlin
package com.tt.honeyDue.viewmodel
|
|
|
|
import com.tt.honeyDue.viewmodel.AuthViewModel
|
|
import com.tt.honeyDue.network.ApiResult
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertIs
|
|
|
|
class AuthViewModelTest {
|
|
|
|
// MARK: - Initialization Tests
|
|
|
|
@Test
|
|
fun testInitialLoginState() {
|
|
// Given
|
|
val viewModel = AuthViewModel()
|
|
|
|
// Then
|
|
assertIs<ApiResult.Idle>(viewModel.loginState.value)
|
|
}
|
|
|
|
@Test
|
|
fun testInitialRegisterState() {
|
|
// Given
|
|
val viewModel = AuthViewModel()
|
|
|
|
// Then
|
|
assertIs<ApiResult.Idle>(viewModel.registerState.value)
|
|
}
|
|
|
|
@Test
|
|
fun testInitialVerifyEmailState() {
|
|
// Given
|
|
val viewModel = AuthViewModel()
|
|
|
|
// Then
|
|
assertIs<ApiResult.Idle>(viewModel.verifyEmailState.value)
|
|
}
|
|
|
|
@Test
|
|
fun testInitialUpdateProfileState() {
|
|
// Given
|
|
val viewModel = AuthViewModel()
|
|
|
|
// Then
|
|
assertIs<ApiResult.Idle>(viewModel.updateProfileState.value)
|
|
}
|
|
|
|
@Test
|
|
fun testResetRegisterState() {
|
|
// Given
|
|
val viewModel = AuthViewModel()
|
|
|
|
// When
|
|
viewModel.resetRegisterState()
|
|
|
|
// Then
|
|
assertIs<ApiResult.Idle>(viewModel.registerState.value)
|
|
}
|
|
|
|
// MARK: - Delete Account Tests
|
|
|
|
@Test
|
|
fun testInitialDeleteAccountState() {
|
|
// Given
|
|
val viewModel = AuthViewModel()
|
|
|
|
// Then
|
|
assertIs<ApiResult.Idle>(viewModel.deleteAccountState.value)
|
|
}
|
|
|
|
@Test
|
|
fun testResetDeleteAccountState() {
|
|
// Given
|
|
val viewModel = AuthViewModel()
|
|
|
|
// When
|
|
viewModel.resetDeleteAccountState()
|
|
|
|
// Then
|
|
assertIs<ApiResult.Idle>(viewModel.deleteAccountState.value)
|
|
}
|
|
}
|