From: David ‘Bombe’ Roden Date: Sun, 20 Nov 2016 15:56:10 +0000 (+0100) Subject: Improve coverage of linked element renderer filter X-Git-Tag: 0.9.7^2~404 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=64127f2f691c8839757e831031a0e9c6fb702a2b;p=Sone.git Improve coverage of linked element renderer filter --- diff --git a/src/test/kotlin/net/pterodactylus/sone/template/LinkedElementRenderFilterTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/LinkedElementRenderFilterTest.kt index 07ef178..c0c83b3 100644 --- a/src/test/kotlin/net/pterodactylus/sone/template/LinkedElementRenderFilterTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/template/LinkedElementRenderFilterTest.kt @@ -5,6 +5,7 @@ import net.pterodactylus.util.template.HtmlFilter import net.pterodactylus.util.template.TemplateContextFactory import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.nullValue import org.jsoup.Jsoup import org.junit.Test @@ -22,6 +23,21 @@ class LinkedElementRenderFilterTest { private val filter = LinkedElementRenderFilter(templateContextFactory) @Test + fun `filter returns null for objects that are not linked elements`() { + assertThat(filter.format(null, Any(), null), nullValue()) + } + + @Test + fun `filter renders loading animation for not loaded elements`() { + val html = filter.format(null, LinkedElement("KSK@gpl.png", loading = true), emptyMap()) as String + val spanNode = Jsoup.parseBodyFragment(html).body().child(0) + assertThat(spanNode.nodeName(), `is`("span")) + assertThat(spanNode.attr("class"), `is`("linked-element")) + assertThat(spanNode.attr("title"), `is`("KSK@gpl.png")) + assertThat(spanNode.attr("style"), `is`("background-image: url('images/loading-animation.gif')")) + } + + @Test fun `filter can render linked images`() { val html = filter.format(null, LinkedElement("KSK@gpl.png"), emptyMap()) as String val linkNode = Jsoup.parseBodyFragment(html).body().child(0)