From: David ‘Bombe’ Roden Date: Mon, 4 May 2015 18:20:05 +0000 (+0200) Subject: Add test for SMBC X-Git-Tag: v2~191 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8c6fbacda7fb8a47533b3d9c42653949527dfb0c;p=rhynodge.git Add test for SMBC --- diff --git a/src/test/java/net/pterodactylus/rhynodge/filters/comics/SaturdayMorningBreakfastCerealComicFilterTest.java b/src/test/java/net/pterodactylus/rhynodge/filters/comics/SaturdayMorningBreakfastCerealComicFilterTest.java new file mode 100644 index 0000000..25e4e28 --- /dev/null +++ b/src/test/java/net/pterodactylus/rhynodge/filters/comics/SaturdayMorningBreakfastCerealComicFilterTest.java @@ -0,0 +1,51 @@ +package net.pterodactylus.rhynodge.filters.comics; + +import java.io.IOException; + +import net.pterodactylus.rhynodge.Filter; +import net.pterodactylus.rhynodge.State; +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; +import org.hamcrest.Matchers; +import org.jsoup.nodes.Document; +import org.junit.Test; + +/** + * Unit test for {@link SaturdayMorningBreakfastCerealComicFilter}. + * + * @author David ‘Bombe’ Roden + */ +public class SaturdayMorningBreakfastCerealComicFilterTest { + + private final Filter smbcFilter = new SaturdayMorningBreakfastCerealComicFilter(); + private final HtmlState htmlState; + + public SaturdayMorningBreakfastCerealComicFilterTest() throws IOException { + Document document = ResourceLoader.loadDocument(SinfestComicFilter.class, "saturday-morning-breakfast-cereal.html", "http://www.smbc-comics.com/"); + htmlState = new HtmlState("http://www.smbc-comics.com/", document); + } + + @Test + public void htmlCanBeParsed() { + State state = smbcFilter.filter(htmlState); + MatcherAssert.assertThat(state, Matchers.instanceOf(ComicState.class)); + } + + @Test + public void comicIsParsedCorrectly() { + ComicState comicState = (ComicState) smbcFilter.filter(htmlState); + MatcherAssert.assertThat(comicState.comics(), Matchers.hasSize(1)); + Comic comic = comicState.comics().get(0); + MatcherAssert.assertThat(comic.title(), Matchers.is("")); + MatcherAssert.assertThat(comic.strips(), Matchers.hasSize(2)); + MatcherAssert.assertThat(comic.strips().get(0).imageUrl(), Matchers.is("http://www.smbc-comics.com/comics/1430750631-20150504.png")); + MatcherAssert.assertThat(comic.strips().get(0).comment(), Matchers.is("And they say there's no use for a liberal arts degree!")); + MatcherAssert.assertThat(comic.strips().get(1).imageUrl(), Matchers.is("http://smbc-comics.com/comics/1430750631-20150504after.png")); + MatcherAssert.assertThat(comic.strips().get(1).comment(), Matchers.is("")); + } + +} diff --git a/src/test/resources/net/pterodactylus/rhynodge/filters/comics/saturday-morning-breakfast-cereal.html b/src/test/resources/net/pterodactylus/rhynodge/filters/comics/saturday-morning-breakfast-cereal.html new file mode 100644 index 0000000..ff32f72 --- /dev/null +++ b/src/test/resources/net/pterodactylus/rhynodge/filters/comics/saturday-morning-breakfast-cereal.html @@ -0,0 +1,208 @@ + + + + + Saturday Morning Breakfast Cereal + + + + + + + + +
+
+
+

+ +
+ +
+
+ +
+ + +
+
+
+
+
May 4, 2015

 Oh, that? That's just ALL OF STARPOCALYPSE FOR FREE!

+

 

+

May 3, 2015
May 2, 2015
May 1, 2015
April 30, 2015
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ + + +
+
+

BAHFest West 2015

+

Oct 22, San Francisco

+

BAHFest East 2015

+

September 19, MIT

+

BAHFest Seattle 2015

+

Date TBD, Seattle

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