Add some tests for the edit image page
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 8 Apr 2017 15:37:58 +0000 (17:37 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 8 Apr 2017 15:37:58 +0000 (17:37 +0200)
src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt

index d36dec5..810e149 100644 (file)
@@ -7,10 +7,10 @@ import net.pterodactylus.sone.data.Sone
 import net.pterodactylus.sone.test.mock
 import net.pterodactylus.sone.test.mockBuilder
 import net.pterodactylus.sone.test.whenever
-import net.pterodactylus.sone.web.pages.EditImagePage
-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.Before
 import org.junit.Test
 import org.mockito.Mockito.never
@@ -41,6 +41,22 @@ class EditImagePageTest : WebPageTest() {
        }
 
        @Test
+       fun `page returns correct path`() {
+               assertThat(page.path, equalTo("editImage.html"))
+       }
+
+       @Test
+       fun `page requires login`() {
+           assertThat(page.requiresLogin(), equalTo(true))
+       }
+
+       @Test
+       fun `page returns correct title`() {
+               whenever(l10n.getString("Page.EditImage.Title")).thenReturn("edit image page title")
+           assertThat(page.getPageTitle(freenetRequest), equalTo("edit image page title"))
+       }
+
+       @Test
        fun `get request does not redirect`() {
                request("", GET)
                page.handleRequest(freenetRequest, templateContext)