From: David ‘Bombe’ Roden Date: Fri, 24 Mar 2017 19:23:55 +0000 (+0100) Subject: Add some tests X-Git-Tag: 0.9.7^2~279 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c5df2a721bbe551ee8fc838c5797b54691149c29;p=Sone.git Add some tests --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/EditAlbumPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/EditAlbumPageTest.kt index 9e3065b..bf3b97f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/EditAlbumPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/EditAlbumPageTest.kt @@ -8,6 +8,8 @@ import net.pterodactylus.sone.test.mockBuilder import net.pterodactylus.sone.test.whenever 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.verify @@ -15,7 +17,7 @@ import org.mockito.Mockito.verify /** * Unit test for [EditAlbumPage]. */ -class EditAlbumPageTest : WebPageTest() { +class EditAlbumPageTest: WebPageTest() { private val page = EditAlbumPage(template, webInterface) @@ -39,6 +41,22 @@ class EditAlbumPageTest : WebPageTest() { } @Test + fun `page returns correct path`() { + assertThat(page.path, equalTo("editAlbum.html")) + } + + @Test + fun `page requires login`() { + assertThat(page.requiresLogin(), equalTo(true)) + } + + @Test + fun `page returns correct title`() { + whenever(l10n.getString("Page.EditAlbum.Title")).thenReturn("edit album page") + assertThat(page.getPageTitle(freenetRequest), equalTo("edit album page")) + } + + @Test fun `get request does not redirect`() { request("", GET) page.handleRequest(freenetRequest, templateContext)