From: David ‘Bombe’ Roden Date: Sun, 20 Sep 2020 11:22:36 +0000 (+0200) Subject: ✅ Add test for QC filter X-Git-Tag: v2~88 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=95e2179643e335a51731c1f3e2c05174f79cf3de;p=rhynodge.git ✅ Add test for QC filter --- diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/QuestionableContentFilterTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/QuestionableContentFilterTest.kt new file mode 100644 index 0000000..39ae500 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/QuestionableContentFilterTest.kt @@ -0,0 +1,29 @@ +package net.pterodactylus.rhynodge.filters.comics + +import net.pterodactylus.rhynodge.filters.ResourceLoader +import net.pterodactylus.rhynodge.states.ComicState +import net.pterodactylus.rhynodge.states.ComicState.Comic +import net.pterodactylus.rhynodge.states.ComicState.Strip +import net.pterodactylus.rhynodge.states.HtmlState +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.contains +import org.junit.Test + +class QuestionableContentFilterTest { + + private val filter = QuestionableContentComicFilter() + private val htmlState: HtmlState = ResourceLoader + .loadDocument(javaClass, "questionable-content.html", baseUrl) + .let { HtmlState(baseUrl, it) } + + @Test + fun `comic is extracted correctly`() { + val comicState = filter.filter(htmlState) as ComicState + assertThat(comicState.comics(), contains( + Comic("").add(Strip("https://www.questionablecontent.net/comics/4355.png", "")) + )) + } + +} + +private const val baseUrl = "https://www.questionablecontent.net/" diff --git a/src/test/resources/net/pterodactylus/rhynodge/filters/comics/questionable-content.html b/src/test/resources/net/pterodactylus/rhynodge/filters/comics/questionable-content.html new file mode 100644 index 0000000..073015e --- /dev/null +++ b/src/test/resources/net/pterodactylus/rhynodge/filters/comics/questionable-content.html @@ -0,0 +1,375 @@ + + + + + + + + + + + + + Questionable Content + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
Menu
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ + + + + + + +
+
+ +
+
+ +
+ + + +
+
+ + + + + + + + + + + +
+ + + + + +
+ +
+
+ September 17, 2020 9:06pm +
+
+ + + +
+
+
+ +
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+
+ + +
+ +
+
Other Good Comics:
+
+ +
+ + • Dave Willis Eats Diapers + + • Diesel Sweeties + + • Doodle For Food + + • Gunnerkrigg Court + + • Johnny Wander + + • Junior Scientist Power Hour + + • Qwantz + + • Sam & Fuzzy + + • Scenes From A Multiverse + + • Something Positive + + • Wasted Talent + + • Wondermark + + • XKCD + + +
+
+ +
+ + Alice Grove • Jeph's music on Bandcamp • QC Forums • Make a donation + • Privacy Policy + + • dord + + • urls +
+ + +
+ + + + +
+ + + +
+ +
+ +
+ +
+ +
+ + + +
+ +
+ + + + + +
+ + + + + + + + + + + + +

+

+ + + +

+ +
+
+ + + +
+ + + + + + + + + + + + +