import net.pterodactylus.sone.data.Sone.SoneStatus.idle
import net.pterodactylus.sone.data.Sone.SoneStatus.inserting
import net.pterodactylus.sone.data.Sone.SoneStatus.unknown
+import net.pterodactylus.sone.freenet.L10nText
import net.pterodactylus.sone.freenet.wot.Identity
import net.pterodactylus.sone.freenet.wot.OwnIdentity
import net.pterodactylus.sone.freenet.wot.Trust
import net.pterodactylus.sone.test.mock
import net.pterodactylus.sone.test.whenever
+import net.pterodactylus.sone.text.TimeText
+import net.pterodactylus.sone.text.TimeTextConverter
import net.pterodactylus.util.template.TemplateContext
import org.hamcrest.Matcher
import org.hamcrest.MatcherAssert.assertThat
class SoneAccessorTest {
private val core = mock<Core>()
- private val accessor = SoneAccessor(core)
+ private val timeTextConverter = mock<TimeTextConverter>()
+ private val accessor = SoneAccessor(core, timeTextConverter)
private val templateContext = mock<TemplateContext>()
private val currentSone = mock<Sone>()
private val currentIdentity = mock<OwnIdentity>()
}
@Test
+ fun `accessor returns l10n text for last update time`() {
+ whenever(sone.time).thenReturn(12345)
+ whenever(timeTextConverter.getTimeText(12345L)).thenReturn(TimeText(L10nText("l10n.key", listOf(3L)), 23456))
+ assertAccessorReturnValue("lastUpdatedText", L10nText("l10n.key", listOf(3L)))
+ }
+
+ @Test
fun `accessor returns null trust if there is no current sone`() {
whenever(templateContext["currentSone"]).thenReturn(null)
assertAccessorReturnValue("trust", null)