From d40b368d639349e880f19f67fd40dd4b50200c82 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 23 May 2017 19:50:23 +0200 Subject: [PATCH] Add more tests for like page --- .../pterodactylus/sone/web/pages/WebPageTest.java | 4 ++++ .../net/pterodactylus/sone/web/pages/LikePageTest.kt | 20 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java b/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java index f341238..bd21b19 100644 --- a/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java +++ b/src/test/java/net/pterodactylus/sone/web/pages/WebPageTest.java @@ -407,4 +407,8 @@ public abstract class WebPageTest { } } + protected void addTranslation(@Nonnull String key, @Nonnull String value) { + when(l10n.getString(key)).thenReturn(value); + } + } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt index 26bd37e..4539269 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/LikePageTest.kt @@ -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) -- 2.7.4