Add more tests for trust page
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 3 Jun 2017 15:42:26 +0000 (17:42 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sun, 4 Jun 2017 09:55:28 +0000 (11:55 +0200)
src/test/kotlin/net/pterodactylus/sone/web/pages/TrustPageTest.kt

index 90a87c6..0273a9f 100644 (file)
@@ -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")