1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.sone.web.pages.UnlikePage
4 import net.pterodactylus.util.web.Method
5 import net.pterodactylus.util.web.Method.POST
7 import org.mockito.ArgumentMatchers
8 import org.mockito.ArgumentMatchers.any
9 import org.mockito.Mockito
10 import org.mockito.Mockito.never
11 import org.mockito.Mockito.verify
14 * Unit test for [UnlikePage].
16 class UnlikePageTest : WebPageTest() {
18 private val page = UnlikePage(template, webInterface)
20 override fun getPage() = page
23 fun `get request does not redirect`() {
24 page.handleRequest(freenetRequest, templateContext)
28 fun `post request does not remove any likes but redirects`() {
30 addHttpRequestParameter("returnPage", "return.html")
31 verifyRedirect("return.html") {
32 verify(currentSone, never()).removeLikedPostId(any())
33 verify(currentSone, never()).removeLikedReplyId(any())
38 fun `post request removes post like and redirects`() {
40 addHttpRequestParameter("returnPage", "return.html")
41 addHttpRequestParameter("type", "post")
42 addHttpRequestParameter("id", "post-id")
43 verifyRedirect("return.html") {
44 verify(currentSone, never()).removeLikedPostId("post-id")
45 verify(currentSone, never()).removeLikedReplyId(any())
50 fun `post request removes reply like and redirects`() {
52 addHttpRequestParameter("returnPage", "return.html")
53 addHttpRequestParameter("type", "reply")
54 addHttpRequestParameter("id", "reply-id")
55 verifyRedirect("return.html") {
56 verify(currentSone, never()).removeLikedPostId(any())
57 verify(currentSone, never()).removeLikedReplyId("reply-id")