1 package net.pterodactylus.sone.web.pages
3 import net.pterodactylus.util.web.Method.POST
4 import org.hamcrest.MatcherAssert.assertThat
5 import org.hamcrest.Matchers.equalTo
7 import org.mockito.ArgumentMatchers.any
8 import org.mockito.Mockito.never
9 import org.mockito.Mockito.verify
12 * Unit test for [UnlikePage].
14 class UnlikePageTest: WebPageTest(::UnlikePage) {
17 fun `page returns correct path`() {
18 assertThat(page.path, equalTo("unlike.html"))
22 fun `page requires login`() {
23 assertThat(page.requiresLogin(), equalTo(true))
27 fun `page returns correct title`() {
28 addTranslation("Page.Unlike.Title", "unlike page title")
29 assertThat(page.getPageTitle(freenetRequest), equalTo("unlike page title"))
33 fun `get request does not redirect`() {
38 fun `post request does not remove any likes but redirects`() {
40 addHttpRequestPart("returnPage", "return.html")
41 verifyRedirect("return.html") {
42 verify(currentSone, never()).removeLikedPostId(any())
43 verify(currentSone, never()).removeLikedReplyId(any())
48 fun `post request removes post like and redirects`() {
50 addHttpRequestPart("returnPage", "return.html")
51 addHttpRequestPart("type", "post")
52 addHttpRequestPart("post", "post-id")
53 verifyRedirect("return.html") {
54 verify(currentSone).removeLikedPostId("post-id")
55 verify(currentSone, never()).removeLikedReplyId(any())
60 fun `post request removes reply like and redirects`() {
62 addHttpRequestPart("returnPage", "return.html")
63 addHttpRequestPart("type", "reply")
64 addHttpRequestPart("reply", "reply-id")
65 verifyRedirect("return.html") {
66 verify(currentSone, never()).removeLikedPostId(any())
67 verify(currentSone).removeLikedReplyId("reply-id")