Use mocked QuoteDateFormatter in TextQuoteCreatorTest
package com.fsck.k9.message.quote
-import android.content.res.Configuration
-import android.content.res.Resources
import com.fsck.k9.Account.QuoteStyle
-import com.fsck.k9.K9
import com.fsck.k9.RobolectricTest
import com.fsck.k9.TestCoreResourceProvider
import com.fsck.k9.crlf
@@ -12,29 +9,24 @@ import com.fsck.k9.mail.Message
import com.fsck.k9.mail.Message.RecipientType
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.doReturn
+import com.nhaarman.mockitokotlin2.eq
import com.nhaarman.mockitokotlin2.mock
import java.util.Date
-import java.util.Locale
-import org.junit.Before
import org.junit.Test
class TextQuoteCreatorTest : RobolectricTest() {
- val resources = mock<Resources> {
- on { configuration } doReturn Configuration().apply { locale = Locale.ROOT }
- }
+ val sentDate = Date(1540421219L)
val originalMessage = mock<Message> {
- on { sentDate } doReturn Date(1540421219L)
+ on { sentDate } doReturn sentDate
on { from } doReturn Address.parse("Alice <alice@sender.example>")
on { getRecipients(RecipientType.TO) } doReturn Address.parse("bob@recipient.example")
on { getRecipients(RecipientType.CC) } doReturn emptyArray<Address>()
on { subject } doReturn "Message subject"
}
- val textQuoteCreator = TextQuoteCreator(QuoteDateFormatter(), TestCoreResourceProvider())
-
- @Before
- fun setUp() {
- K9.isHideTimeZone = true
+ val quoteDateFormatter = mock<QuoteDateFormatter> {
+ on { format(eq(sentDate)) } doReturn "January 18, 1970 7:53:41 PM UTC"
}
+ val textQuoteCreator = TextQuoteCreator(quoteDateFormatter, TestCoreResourceProvider())
@Test
fun prefixQuote() {
