Add test for about page
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 11 Oct 2016 19:11:14 +0000 (21:11 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 11 Oct 2016 19:11:14 +0000 (21:11 +0200)
src/test/java/net/pterodactylus/sone/web/AboutPageTest.java [new file with mode: 0644]

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 (file)
index 0000000..df41e61
--- /dev/null
@@ -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 <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+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));
+       }
+
+}