1 package net.pterodactylus.rhynodge.filters.comics
3 import net.pterodactylus.rhynodge.filters.ResourceLoader
4 import net.pterodactylus.rhynodge.states.ComicState
5 import net.pterodactylus.rhynodge.states.HtmlState
6 import org.hamcrest.MatcherAssert.assertThat
7 import org.hamcrest.Matchers.*
11 * Unit test for [SaturdayMorningBreakfastCerealComicFilter].
13 class SaturdayMorningBreakfastCerealComicFilterTest {
15 private val smbcFilter = SaturdayMorningBreakfastCerealComicFilter()
16 private val htmlState = ResourceLoader.loadDocument(SinfestComicFilter::class.java, "saturday-morning-breakfast-cereal.html", "http://www.smbc-comics.com/").let {
17 HtmlState("http://www.smbc-comics.com/", it)
21 fun htmlCanBeParsed() {
22 val state = smbcFilter.filter(htmlState)
23 assertThat(state, instanceOf(ComicState::class.java))
27 fun comicIsParsedCorrectly() {
28 val comicState = smbcFilter.filter(htmlState) as ComicState
29 assertThat(comicState.comics(), hasSize(1))
30 val comic = comicState.comics().first()
31 assertThat(comic.title(), equalTo(""))
32 assertThat(comic.strips(), hasSize(2))
33 comic.strips().first().also { firstImage ->
34 assertThat(firstImage.imageUrl(), equalTo("http://www.smbc-comics.com/comics/1496144390-soonish6%20(1).png"))
35 assertThat(firstImage.comment(), equalTo("It's not an old man rant if you put it in the mouths of children!"))
37 comic.strips()[1].also { secondImage ->
38 assertThat(secondImage.imageUrl(), equalTo("http://smbc-comics.com/comics/1496144435-soonish6after.png"))
39 assertThat(secondImage.comment(), equalTo(""))