From: David ‘Bombe’ Roden Date: Sun, 4 Jun 2017 09:47:03 +0000 (+0200) Subject: Add more tests and fix tests for unlike page X-Git-Tag: 0.9.7^2~177 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=c51621d31bf28dca5308497453030263ccac2b06;p=Sone.git Add more tests and fix tests for unlike page --- diff --git a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlikePageTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlikePageTest.kt index 3fa84fd..852a6c4 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlikePageTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/pages/UnlikePageTest.kt @@ -1,6 +1,8 @@ package net.pterodactylus.sone.web.pages import net.pterodactylus.util.web.Method.POST +import org.hamcrest.MatcherAssert.assertThat +import org.hamcrest.Matchers.equalTo import org.junit.Test import org.mockito.ArgumentMatchers.any import org.mockito.Mockito.never @@ -16,6 +18,22 @@ class UnlikePageTest : WebPageTest() { override fun getPage() = page @Test + fun `page returns correct path`() { + assertThat(page.path, equalTo("unlike.html")) + } + + @Test + fun `page requires login`() { + assertThat(page.requiresLogin(), equalTo(true)) + } + + @Test + fun `page returns correct title`() { + addTranslation("Page.Unlike.Title", "unlike page title") + assertThat(page.getPageTitle(freenetRequest), equalTo("unlike page title")) + } + + @Test fun `get request does not redirect`() { verifyNoRedirect { } } @@ -35,9 +53,9 @@ class UnlikePageTest : WebPageTest() { setMethod(POST) addHttpRequestPart("returnPage", "return.html") addHttpRequestPart("type", "post") - addHttpRequestPart("id", "post-id") + addHttpRequestPart("post", "post-id") verifyRedirect("return.html") { - verify(currentSone, never()).removeLikedPostId("post-id") + verify(currentSone).removeLikedPostId("post-id") verify(currentSone, never()).removeLikedReplyId(any()) } } @@ -47,10 +65,10 @@ class UnlikePageTest : WebPageTest() { setMethod(POST) addHttpRequestPart("returnPage", "return.html") addHttpRequestPart("type", "reply") - addHttpRequestPart("id", "reply-id") + addHttpRequestPart("reply", "reply-id") verifyRedirect("return.html") { verify(currentSone, never()).removeLikedPostId(any()) - verify(currentSone, never()).removeLikedReplyId("reply-id") + verify(currentSone).removeLikedReplyId("reply-id") } }