X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FViewSonePageTest.kt;fp=src%2Ftest%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fpages%2FViewSonePageTest.kt;h=7161684e6d07c88b38b467797d7b33859d8b66db;hb=4f2dd6da42af253e7545d7cba5d9e5cb2895eb34;hp=335d839e12381e2fa5368ae877fbd5fd40cb6d5b;hpb=5ba707d40f9d2a20094aaabc21647aeec1feed46;p=Sone.git 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 335d839..7161684 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/ViewSonePageTest.kt @@ -42,17 +42,19 @@ class ViewSonePageTest : WebPageTest() { @Test fun `get request without sone parameter stores null in template context`() { - page.handleRequest(freenetRequest, templateContext) - assertThat(templateContext["sone"], nullValue()) - assertThat(templateContext["soneId"], equalTo("")) + verifyNoRedirect { + assertThat(templateContext["sone"], nullValue()) + assertThat(templateContext["soneId"], equalTo("")) + } } @Test fun `get request with invalid sone parameter stores null in template context`() { addHttpRequestParameter("sone", "invalid-sone-id") - page.handleRequest(freenetRequest, templateContext) - assertThat(templateContext["sone"], nullValue()) - assertThat(templateContext["soneId"], equalTo("invalid-sone-id")) + verifyNoRedirect { + assertThat(templateContext["sone"], nullValue()) + assertThat(templateContext["soneId"], equalTo("invalid-sone-id")) + } } @Test @@ -61,9 +63,10 @@ class ViewSonePageTest : WebPageTest() { whenever(core.getDirectedPosts("sone-id")).thenReturn(emptyList()) addHttpRequestParameter("sone", "sone-id") addSone("sone-id", currentSone) - page.handleRequest(freenetRequest, templateContext) - assertThat(templateContext["sone"], equalTo(currentSone)) - assertThat(templateContext["soneId"], equalTo("sone-id")) + verifyNoRedirect { + assertThat(templateContext["sone"], equalTo(currentSone)) + assertThat(templateContext["soneId"], equalTo("sone-id")) + } } private fun createPost(id: String, text: String, time: Long, sender: Sone? = null, recipient: Sone? = null) = mock().apply { @@ -81,8 +84,9 @@ class ViewSonePageTest : WebPageTest() { fun `request with valid sone stores posts and directed posts in template context`() { addSone("sone-id", currentSone) addHttpRequestParameter("sone", "sone-id") - page.handleRequest(freenetRequest, templateContext) - assertThat(templateContext["posts"] as Iterable, contains(directed2, post2)) + verifyNoRedirect { + assertThat(templateContext["posts"] as Iterable, contains(directed2, post2)) + } } @Test @@ -91,8 +95,9 @@ class ViewSonePageTest : WebPageTest() { addSone("sone-id", currentSone) addHttpRequestParameter("sone", "sone-id") addHttpRequestParameter("postPage", "1") - page.handleRequest(freenetRequest, templateContext) - assertThat(templateContext["posts"] as Iterable, contains(directed1, post1)) + verifyNoRedirect { + assertThat(templateContext["posts"] as Iterable, contains(directed1, post1)) + } } private fun createReply(text: String, time: Long, post: Post?) = mock().apply { @@ -120,8 +125,9 @@ class ViewSonePageTest : WebPageTest() { whenever(core.getReplies("post3")).thenReturn(listOf(reply6)) addSone("sone-id", currentSone) addHttpRequestParameter("sone", "sone-id") - page.handleRequest(freenetRequest, templateContext) - assertThat(templateContext["repliedPosts"] as Iterable, contains(foreignPost2, foreignPost1)) + verifyNoRedirect { + assertThat(templateContext["repliedPosts"] as Iterable, contains(foreignPost2, foreignPost1)) + } } @Test