Skip to content

Commit

Permalink
OutgoingServerSettingsStateMapperKtTest : Updated Tests related to nu…
Browse files Browse the repository at this point in the history
…ll server settings so state obtain server name as emailDomain dot prefix.

IncomingServerSettingsStateMapperKtTest : replaced emailAddress field in accountState from hardcoded string to local variable  in a test.
  • Loading branch information
shamim-emon committed Feb 18, 2025
1 parent 1341912 commit 4bd8475
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ import org.junit.Test

class IncomingServerSettingsStateMapperKtTest {

@Suppress("MaxLineLength")
@Test
fun `should map to state with email as username and emailDomain With dot prefix as server name when server settings are null`() {
val email = "[email protected]"
val accountState = AccountState(
emailAddress = "[email protected]",
emailAddress = email,
incomingServerSettings = null,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import app.k9mail.feature.account.common.domain.entity.ConnectionSecurity
import app.k9mail.feature.account.common.domain.entity.MailConnectionSecurity
import app.k9mail.feature.account.common.domain.input.NumberInputField
import app.k9mail.feature.account.common.domain.input.StringInputField
import app.k9mail.feature.account.server.settings.ui.common.toInvalidEmailDomain
import app.k9mail.feature.account.server.settings.ui.outgoing.OutgoingServerSettingsContract.State
import assertk.assertThat
import assertk.assertions.isEqualTo
Expand All @@ -15,26 +16,31 @@ import org.junit.Test

class OutgoingServerSettingsStateMapperKtTest {

@Suppress("MaxLineLength")
@Test
fun `should map to state with email as username when server settings are null`() {
fun `should map to state with email as username and emailDomain With dot prefix as server name when server settings are null`() {
val email = "[email protected]"
val accountState = AccountState(
emailAddress = "[email protected]",
emailAddress = email,
outgoingServerSettings = null,
)

val result = accountState.toOutgoingServerSettingsState()

assertThat(result).isEqualTo(
State(
username = StringInputField(value = "[email protected]"),
username = StringInputField(value = email),
server = StringInputField(value = email.toInvalidEmailDomain()),
),
)
}

@Suppress("MaxLineLength")
@Test
fun `should map to state with password from incomingServerSettings when outgoingServerSettings is null`() {
fun `should map to state with password from incomingServerSettings and emailDomain With dot prefix as server name when outgoingServerSettings is null`() {
val email = "[email protected]"
val accountState = AccountState(
emailAddress = "[email protected]",
emailAddress = email,
incomingServerSettings = IMAP_SERVER_SETTINGS,
outgoingServerSettings = null,
)
Expand All @@ -43,8 +49,9 @@ class OutgoingServerSettingsStateMapperKtTest {

assertThat(result).isEqualTo(
State(
username = StringInputField(value = "[email protected]"),
username = StringInputField(value = email),
password = StringInputField(value = INCOMING_SERVER_PASSWORD),
server = StringInputField(value = email.toInvalidEmailDomain()),
),
)
}
Expand Down

0 comments on commit 4bd8475

Please sign in to comment.