Add more tests for like page
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 23 May 2017 17:50:23 +0000 (19:50 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 23 May 2017 17:50:23 +0000 (19:50 +0200)
src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java
src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt

index f341238..bd21b19 100644 (file)
@@ -407,4 +407,8 @@ public abstract class WebPageTest {
                }
        }
 
+       protected void addTranslation(@Nonnull String key, @Nonnull String value) {
+               when(l10n.getString(key)).thenReturn(value);
+       }
+
 }
index 26bd37e..4539269 100644 (file)
@@ -1,9 +1,9 @@
 package net.pterodactylus.sone.web.pages
 
-import net.pterodactylus.sone.web.pages.LikePage
-import net.pterodactylus.sone.web.pages.WebPageTest
 import net.pterodactylus.util.web.Method.GET
 import net.pterodactylus.util.web.Method.POST
+import org.hamcrest.MatcherAssert.assertThat
+import org.hamcrest.Matchers.equalTo
 import org.junit.Test
 import org.mockito.Mockito.verify
 import org.mockito.Mockito.verifyNoMoreInteractions
@@ -18,6 +18,22 @@ class LikePageTest : WebPageTest() {
        override fun getPage() = page
 
        @Test
+       fun `page returns correct path`() {
+           assertThat(page.path, equalTo("like.html"))
+       }
+
+       @Test
+       fun `page requires login`() {
+           assertThat(page.requiresLogin(), equalTo(true))
+       }
+
+       @Test
+       fun `page returns correct title`() {
+           addTranslation("Page.Like.Title", "like page title")
+               assertThat(page.getPageTitle(freenetRequest), equalTo("like page title"))
+       }
+
+       @Test
        fun `get request does not redirect`() {
                request("", GET)
                page.handleRequest(freenetRequest, templateContext)