1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.web.pages.LikePage
4 import net.pterodactylus.sone.web.pages.WebPageTest
5 import net.pterodactylus.util.web.Method.GET
6 import net.pterodactylus.util.web.Method.POST
8 import org.mockito.Mockito.verify
9 import org.mockito.Mockito.verifyNoMoreInteractions
12 * Unit test for [LikePage].
14 class LikePageTest : WebPageTest() {
16 private val page = LikePage(template, webInterface)
18 override fun getPage() = page
21 fun `get request does not redirect`() {
23 page.handleRequest(freenetRequest, templateContext)
27 fun `post request with post id likes post and redirects to return page`() {
29 addHttpRequestParameter("type", "post")
30 addHttpRequestParameter("post", "post-id")
31 addHttpRequestParameter("returnPage", "return.html")
32 verifyRedirect("return.html") {
33 verify(currentSone).addLikedPostId("post-id")
38 fun `post request with reply id likes post and redirects to return page`() {
40 addHttpRequestParameter("type", "reply")
41 addHttpRequestParameter("reply", "reply-id")
42 addHttpRequestParameter("returnPage", "return.html")
43 verifyRedirect("return.html") {
44 verify(currentSone).addLikedReplyId("reply-id")
49 fun `post request with invalid likes redirects to return page`() {
51 addHttpRequestParameter("type", "foo")
52 addHttpRequestParameter("returnPage", "return.html")
53 verifyRedirect("return.html") {
54 verifyNoMoreInteractions(currentSone)