From: David ‘Bombe’ Roden Date: Tue, 11 Oct 2016 19:11:14 +0000 (+0200) Subject: Add test for about page X-Git-Tag: 0.9.6^2~26 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=a499658371a06dd52191bd6c0fed6542cfd1e9b0;p=Sone.git Add test for about page --- diff --git a/src/test/java/net/pterodactylus/sone/web/AboutPageTest.java b/src/test/java/net/pterodactylus/sone/web/AboutPageTest.java new file mode 100644 index 0000000..df41e61 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/web/AboutPageTest.java @@ -0,0 +1,43 @@ +package net.pterodactylus.sone.web; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import org.junit.Test; + +/** + * Unit test for {@link AboutPage}. + * + * @author David ‘Bombe’ Roden + */ +public class AboutPageTest extends WebPageTest { + + private final String version = "0.1.2"; + private final int year = 1234; + private final String homepage = "home://page"; + private final AboutPage page = new AboutPage(template, webInterface, version, year, homepage); + + @Test + public void pageReturnsCorrectPath() { + assertThat(page.getPath(), is("about.html")); + } + + @Test + public void pageSetsCorrectVersionInTemplateContext() throws Exception { + page.processTemplate(freenetRequest, templateContext); + assertThat(templateContext.get("version"), is((Object) version)); + } + + @Test + public void pageSetsCorrectHomepageInTemplateContext() throws Exception { + page.processTemplate(freenetRequest, templateContext); + assertThat(templateContext.get("homepage"), is((Object) homepage)); + } + + @Test + public void pageSetsCorrectYearInTemplateContext() throws Exception { + page.processTemplate(freenetRequest, templateContext); + assertThat(templateContext.get("year"), is((Object) year)); + } + +}