From: David ‘Bombe’ Roden Date: Thu, 20 Jan 2022 20:35:16 +0000 (+0100) Subject: ✅ Add base class for comic tests X-Git-Tag: v2~57 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a2dfe4d171bc4e13c8998ab2ae14b1e33169edfb;hp=889e90982cf5921836868b42f1191502ef270d24;p=rhynodge.git ✅ Add base class for comic tests --- diff --git a/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/ComicSiteFilterTest.kt b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/ComicSiteFilterTest.kt new file mode 100644 index 0000000..ce1a8e2 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/rhynodge/filters/comics/ComicSiteFilterTest.kt @@ -0,0 +1,31 @@ +package net.pterodactylus.rhynodge.filters.comics + +import net.pterodactylus.rhynodge.filters.ComicSiteFilter +import net.pterodactylus.rhynodge.filters.ResourceLoader +import net.pterodactylus.rhynodge.states.ComicState +import net.pterodactylus.rhynodge.states.ComicState.Comic +import net.pterodactylus.rhynodge.states.HtmlState +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo +import org.junit.Test + +abstract class ComicSiteFilterTest { + + protected abstract val filter: ComicSiteFilter + protected abstract val baseUrl: String + protected abstract val resource: String + protected abstract val expectedComics: List + + private val htmlState: HtmlState by lazy { + ResourceLoader + .loadDocument(javaClass, resource, baseUrl) + .let { HtmlState(baseUrl, it) } + } + + @Test + fun `comic is loaded correctly`() { + val comicState = filter.filter(htmlState) as ComicState + assertThat(comicState.comics(), equalTo(expectedComics)) + } + +}