From d42da49d38b464416be5d74c167ef6b02bd1ccc7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 8 Apr 2017 17:37:58 +0200 Subject: [PATCH] Add some tests for the edit image page --- .../sone/web/pages/EditImagePageTest.kt | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt index d36dec5..810e149 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/EditImagePageTest.kt @@ -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) -- 2.7.4