🎨 Use equalTo instead of is
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 9 Mar 2019 16:54:18 +0000 (17:54 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 9 Mar 2019 16:54:18 +0000 (17:54 +0100)
src/test/kotlin/net/pterodactylus/sone/template/LinkedElementRenderFilterTest.kt

index 31bc4eb..8ea0fa3 100644 (file)
@@ -8,14 +8,10 @@ import net.pterodactylus.util.template.ClassPathTemplateProvider
 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.contains
-import org.hamcrest.Matchers.equalTo
-import org.hamcrest.Matchers.notNullValue
-import org.hamcrest.Matchers.nullValue
 import org.jsoup.Jsoup
 import org.jsoup.nodes.Element
 import org.junit.Test
+import org.hamcrest.Matchers.*
 
 /**
  * Unit test for [LinkedElementRenderFilter].
@@ -40,25 +36,25 @@ class LinkedElementRenderFilterTest {
        fun `filter renders empty span 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 not-loaded"))
-               assertThat(spanNode.attr("title"), `is`("KSK@gpl.png"))
-               assertThat(spanNode.hasAttr("style"), `is`(false))
-               assertThat(spanNode.children().isEmpty(), `is`(true))
+               assertThat(spanNode.nodeName(), equalTo("span"))
+               assertThat(spanNode.attr("class"), equalTo("linked-element not-loaded"))
+               assertThat(spanNode.attr("title"), equalTo("KSK@gpl.png"))
+               assertThat(spanNode.hasAttr("style"), equalTo(false))
+               assertThat(spanNode.children().isEmpty(), equalTo(true))
        }
 
        @Test
        fun `filter can render linked images`() {
                val html = filter.format(null, LinkedElement("KSK@gpl.png", properties = mapOf("type" to "image")), emptyMap()) as String
                val outerSpanNode = Jsoup.parseBodyFragment(html).body().child(0)
-               assertThat(outerSpanNode.nodeName(), `is`("span"))
-               assertThat(outerSpanNode.attr("class"), `is`("linked-element loaded"))
-               assertThat(outerSpanNode.attr("title"), `is`("KSK@gpl.png"))
+               assertThat(outerSpanNode.nodeName(), equalTo("span"))
+               assertThat(outerSpanNode.attr("class"), equalTo("linked-element loaded"))
+               assertThat(outerSpanNode.attr("title"), equalTo("KSK@gpl.png"))
                val linkNode = outerSpanNode.child(0)
-               assertThat(linkNode.nodeName(), `is`("a"))
-               assertThat(linkNode.attr("href"), `is`("/KSK@gpl.png"))
+               assertThat(linkNode.nodeName(), equalTo("a"))
+               assertThat(linkNode.attr("href"), equalTo("/KSK@gpl.png"))
                val innerSpanNode = linkNode.child(0)
-               assertThat(innerSpanNode.attr("style"), `is`("background-image: url('/KSK@gpl.png')"))
+               assertThat(innerSpanNode.attr("style"), equalTo("background-image: url('/KSK@gpl.png')"))
        }
 
        @Test
@@ -66,8 +62,8 @@ class LinkedElementRenderFilterTest {
                val html = filter.format(null, LinkedElement("KSK@gpl.html", properties = mapOf("type" to "html", "title" to "Page Title", "description" to "This is the description.")), emptyMap()) as String
                val outerSpanNode = Jsoup.parseBodyFragment(html).body().child(0)
                assertThat(outerSpanNode.nodeName(), equalTo("span"))
-               assertThat(outerSpanNode.attr("class"), `is`("linked-element loaded"))
-               assertThat(outerSpanNode.attr("title"), `is`("KSK@gpl.html"))
+               assertThat(outerSpanNode.attr("class"), equalTo("linked-element loaded"))
+               assertThat(outerSpanNode.attr("title"), equalTo("KSK@gpl.html"))
                val linkNode = outerSpanNode.child(0)
                assertThat(linkNode.nodeName(), equalTo("a"))
                assertThat(linkNode.attr("href"), equalTo("/KSK@gpl.html"))