X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FPostAccessorTest.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FPostAccessorTest.kt;h=bb92810cf08222e8cc0ab87aa348738483335a2f;hb=de6be950b15db8012395f43217af6565fadecbf4;hp=72e1343fd59503a503946b57e8fab0205181e0fb;hpb=d6b2d0c11e128ecdda742f060acf94036f7cd87b;p=Sone.git diff --git a/src/test/kotlin/net/pterodactylus/sone/template/PostAccessorTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/PostAccessorTest.kt index 72e1343..bb92810 100644 --- a/src/test/kotlin/net/pterodactylus/sone/template/PostAccessorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/template/PostAccessorTest.kt @@ -3,6 +3,7 @@ package net.pterodactylus.sone.template import net.pterodactylus.sone.core.* import net.pterodactylus.sone.data.* import net.pterodactylus.sone.test.* +import net.pterodactylus.sone.utils.* import net.pterodactylus.util.template.* import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* @@ -165,6 +166,14 @@ class PostAccessorTest { } @Test + fun `reply sone for post directed at local sone is local sone`() { + val localSone = mockLocalSone() + val post = mockPostFrom(remoteSone, localSone) + assertThat(accessor[templateContext, post, "replySone"], equalTo(localSone)) + } + + + @Test fun `accessor returns other properties`() { assertThat(accessor[null, post, "hashCode"], equalTo(post.hashCode())) } @@ -179,9 +188,10 @@ private val templateContext = TemplateContext().apply { this["currentSone"] = currentSone } -private fun mockPostFrom(sone: Sone) = mock().apply { +private fun mockPostFrom(sone: Sone, recipient: Sone? = null) = mock().apply { whenever(id).thenReturn("post-id") whenever(this.sone).thenReturn(sone) + whenever(this.recipient).thenReturn(recipient.asOptional()) } private fun mockReplyFrom(sone: Sone) = mock().apply { whenever(this.sone).thenReturn(sone) }