From 2cdde02993e81e73a3b7edc3bcee13f56b43d6d5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 3 Jun 2017 17:42:26 +0200 Subject: [PATCH] Add more tests for trust page --- .../pterodactylus/sone/web/pages/TrustPageTest.kt | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt index 90a87c6..0273a9f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt @@ -3,6 +3,8 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.sone.data.Sone import net.pterodactylus.sone.test.mock import net.pterodactylus.util.web.Method.POST +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo import org.junit.Test import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.eq @@ -19,11 +21,36 @@ class TrustPageTest : WebPageTest() { override fun getPage() = page @Test + fun `page returns correct path`() { + assertThat(page.path, equalTo("trust.html")) + } + + @Test + fun `page requires login`() { + assertThat(page.requiresLogin(), equalTo(true)) + } + + @Test + fun `page returns correct title`() { + addTranslation("Page.Trust.Title", "title trust page") + assertThat(page.getPageTitle(freenetRequest), equalTo("title trust page")) + } + + @Test fun `get method does not redirect`() { verifyNoRedirect { } } @Test + fun `post request without sone redirects to return page`() { + setMethod(POST) + addHttpRequestPart("returnPage", "return.html") + verifyRedirect("return.html") { + verify(core, never()).trustSone(eq(currentSone), any()) + } + } + + @Test fun `post request with missing sone redirects to return page`() { setMethod(POST) addHttpRequestPart("returnPage", "return.html") -- 2.7.4