Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Sent” folder: Missing space between "To" and address #8259

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MessageHelper(
}
val repository = if (isShowContactName) contactRepository else null
val recipients = toFriendly(addresses, repository)
return SpannableStringBuilder(resourceProvider.contactDisplayNamePrefix()).append(recipients)
return SpannableStringBuilder(resourceProvider.contactDisplayNamePrefix()).append(' ').append(recipients)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import app.k9mail.core.common.mail.toEmailAddressOrThrow
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isInstanceOf
import com.fsck.k9.CoreResourceProvider
import com.fsck.k9.TestCoreResourceProvider
import com.fsck.k9.helper.MessageHelper.Companion.toFriendly
import com.fsck.k9.mail.Address
import org.junit.Test
Expand All @@ -20,6 +22,8 @@ import org.mockito.kotlin.stub
class MessageHelperTest : RobolectricTest() {

private val contactRepository: ContactRepository = mock()
private val resourceProvider: CoreResourceProvider = TestCoreResourceProvider()
private val messageHelper: MessageHelper = MessageHelper(resourceProvider, contactRepository)

@Test
fun testToFriendlyShowsPersonalPartIfItExists() {
Expand Down Expand Up @@ -116,6 +120,32 @@ class MessageHelperTest : RobolectricTest() {
assertThat(friendly).isEqualTo("Tim@Testor")
}

@Test
fun testGetSenderDisplayNameWithShowContactNameShouldReturnCorrectOutput() {
val address1 = Address("test@testor.com", "Tim Testor")
val address2 = Address("foo@bar.com", "Foo Bar")
val addresses = arrayOf(address1, address2)
setupContactRepositoryWithFakeContact(EMAIL_ADDRESS)
val displayName = messageHelper.getRecipientDisplayNames(addresses)
assertThat(displayName.toString()).isEqualTo("To: Tim Testor,Foo Bar")
}

@Test
fun testGetSenderDisplayNameWithoutShowContactNameShouldReturnCorrectOutput() {
val address1 = Address("test@testor.com")
val address2 = Address("foo@bar.com")
val addresses = arrayOf(address1, address2)

val displayName = messageHelper.getRecipientDisplayNames(addresses)
assertThat(displayName.toString()).isEqualTo("To: test@testor.com,foo@bar.com")
}

@Test
fun testGetSenderDisplayNameWithoutInputReturnCorrectOutput() {
val displayName = messageHelper.getRecipientDisplayNames(null)
assertThat(displayName.toString()).isEqualTo(resourceProvider.contactUnknownRecipient())
}

private fun setupContactRepositoryWithFakeContact(emailAddress: EmailAddress) {
contactRepository.stub {
on { getContactFor(emailAddress) } doReturn
Expand Down