From: David ‘Bombe’ Roden Date: Sun, 4 Jun 2017 22:20:34 +0000 (+0200) Subject: Add and improve tests for view Sone page X-Git-Tag: 0.9.7^2~164 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1604283131120a5b4eb17a856ea688a20c03dc60;p=Sone.git Add and improve tests for view Sone page --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt index 6850cf1..6b5a08f 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt @@ -17,7 +17,7 @@ import org.junit.Test /** * Unit test for [ViewSonePage]. */ -class ViewSonePageTest : WebPageTest() { +class ViewSonePageTest: WebPageTest() { init { whenever(currentSone.id).thenReturn("sone-id") @@ -41,6 +41,16 @@ class ViewSonePageTest : WebPageTest() { } @Test + fun `page returns correct path`() { + assertThat(page.path, equalTo("viewSone.html")) + } + + @Test + fun `page does not require login`() { + assertThat(page.requiresLogin(), equalTo(false)) + } + + @Test fun `get request without sone parameter stores null in template context`() { verifyNoRedirect { assertThat(templateContext["sone"], nullValue()) @@ -132,13 +142,15 @@ class ViewSonePageTest : WebPageTest() { @Test fun `page title is default for request without parameters`() { - assertThat(page.getPageTitle(freenetRequest), equalTo("Page.ViewSone.Page.TitleWithoutSone")) + addTranslation("Page.ViewSone.Page.TitleWithoutSone", "view sone page without sone") + assertThat(page.getPageTitle(freenetRequest), equalTo("view sone page without sone")) } @Test fun `page title is default for request with invalid sone parameters`() { addHttpRequestParameter("sone", "invalid-sone-id") - assertThat(page.getPageTitle(freenetRequest), equalTo("Page.ViewSone.Page.TitleWithoutSone")) + addTranslation("Page.ViewSone.Page.TitleWithoutSone", "view sone page without sone") + assertThat(page.getPageTitle(freenetRequest), equalTo("view sone page without sone")) } @Test @@ -150,7 +162,8 @@ class ViewSonePageTest : WebPageTest() { middleName = "M." lastName = "Last" }) - assertThat(page.getPageTitle(freenetRequest), equalTo("First M. Last - Page.ViewSone.Title")) + addTranslation("Page.ViewSone.Title", "view sone page") + assertThat(page.getPageTitle(freenetRequest), equalTo("First M. Last - view sone page")) } @Test