From: David ‘Bombe’ Roden Date: Sun, 4 Jun 2017 17:35:10 +0000 (+0200) Subject: Add and improve tests for view post page X-Git-Tag: 0.9.7^2~166 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=78c208e6b826eb2a032c6c1911a7a8e59eb174fb;p=Sone.git Add and improve tests for view post page --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt index 88ca34a..8776af7 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewPostPageTest.kt @@ -12,7 +12,7 @@ import org.junit.Test /** * Unit test for [ViewPostPage]. */ -class ViewPostPageTest : WebPageTest() { +class ViewPostPageTest: WebPageTest() { private val page = ViewPostPage(template, webInterface) private val post = mock() @@ -20,6 +20,16 @@ class ViewPostPageTest : WebPageTest() { override fun getPage() = page @Test + fun `page returns correct path`() { + assertThat(page.path, equalTo("viewPost.html")) + } + + @Test + fun `page does not require login`() { + assertThat(page.requiresLogin(), equalTo(false)) + } + + @Test fun `the view post page is link-excepted`() { assertThat(page.isLinkExcepted(null), equalTo(true)) } @@ -64,13 +74,15 @@ class ViewPostPageTest : WebPageTest() { @Test fun `page title for request without parameters is default title`() { - assertThat(page.getPageTitle(freenetRequest), equalTo("Page.ViewPost.Title")) + addTranslation("Page.ViewPost.Title", "view post title") + assertThat(page.getPageTitle(freenetRequest), equalTo("view post title")) } @Test fun `page title for request with invalid post is default title`() { addHttpRequestParameter("post", "invalid-post-id") - assertThat(page.getPageTitle(freenetRequest), equalTo("Page.ViewPost.Title")) + addTranslation("Page.ViewPost.Title", "view post title") + assertThat(page.getPageTitle(freenetRequest), equalTo("view post title")) } @Test @@ -84,7 +96,8 @@ class ViewPostPageTest : WebPageTest() { whenever(post.text).thenReturn("This is a text that is longer than twenty characters.") addPost("post-id", post) addHttpRequestParameter("post", "post-id") - assertThat(page.getPageTitle(freenetRequest), equalTo("This is a text that … - First M. Last - Page.ViewPost.Title")) + addTranslation("Page.ViewPost.Title", "view post title") + assertThat(page.getPageTitle(freenetRequest), equalTo("This is a text that … - First M. Last - view post title")) } }