From 1604283131120a5b4eb17a856ea688a20c03dc60 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 5 Jun 2017 00:20:34 +0200 Subject: [PATCH] Add and improve tests for view Sone page --- .../sone/web/pages/ViewSonePageTest.kt | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 -- 2.7.4